Help
I am currently working on Victim Of Life to get it to work, but I have a problem with a script.
void main( void )
{
int &karl = create_sprite(290, 230, 16, 381, 1);
sp_speed(&karl, 2);
sp_base_walk(&karl, 380);
preload_seq(381);
preload_seq(383);
preload_seq(385);
preload_seq(387);
preload_seq(389);
void talk(void)
{
freeze(&karl);
freeze(1);
choice_start()
"have you seen a guy named David"
"who are you"
"nevermind"
choice_end()
unfreeze(1);
unfreeze(&karl);
if (&result == 1)
{
freeze(1);
freeze(&karl);
say_stop("have you seen a guy named David", 1);
say_stop("`0maybe. I saw a guy with blue clothes for some minuttes ago", &karl);
say_stop("Ok?", 1);
say_stop("`0I saw him with a famer ", &karl);
say_stop("where did he go", 1);
say_stop("`0I don`t know", &karl);
say_stop("Ok thanks", 1);
unfreeze(1);
unfreeze(&karl);
}
if (&result == 2)
{
freeze(1);
freeze(&karl);
say_stop("Hi what is your name?", 1);
say_stop("`0My name is Carl", &karl);
unfreeze(1);
unfreeze(&karl);
}
}
}
The sprite gets created, but it wont talk.
void main( void )
{
int &karl = create_sprite(290, 230, 16, 381, 1);
sp_speed(&karl, 2);
sp_base_walk(&karl, 380);
preload_seq(381);
preload_seq(383);
preload_seq(385);
preload_seq(387);
preload_seq(389);
void talk(void)
{
freeze(&karl);
freeze(1);
choice_start()
"have you seen a guy named David"
"who are you"
"nevermind"
choice_end()
unfreeze(1);
unfreeze(&karl);
if (&result == 1)
{
freeze(1);
freeze(&karl);
say_stop("have you seen a guy named David", 1);
say_stop("`0maybe. I saw a guy with blue clothes for some minuttes ago", &karl);
say_stop("Ok?", 1);
say_stop("`0I saw him with a famer ", &karl);
say_stop("where did he go", 1);
say_stop("`0I don`t know", &karl);
say_stop("Ok thanks", 1);
unfreeze(1);
unfreeze(&karl);
}
if (&result == 2)
{
freeze(1);
freeze(&karl);
say_stop("Hi what is your name?", 1);
say_stop("`0My name is Carl", &karl);
unfreeze(1);
unfreeze(&karl);
}
}
}
The sprite gets created, but it wont talk.
Try a closing bracket } after preload_seq(389); to close void main(void) and remove the redundant one at the bottom (you only need two closing brackets there because you only need to close the second if-statement and the void talk(void) procedure.
So try:
void main( void )
{
int &karl = create_sprite(290, 230, 16, 381, 1);
sp_speed(&karl, 2);
sp_base_walk(&karl, 380);
preload_seq(381);
preload_seq(383);
preload_seq(385);
preload_seq(387);
preload_seq(389);
}
void talk(void)
{
freeze(&karl);
freeze(1);
choice_start()
"have you seen a guy named David"
"who are you"
"nevermind"
choice_end()
unfreeze(1);
unfreeze(&karl);
if (&result == 1)
{
freeze(1);
freeze(&karl);
say_stop("have you seen a guy named David", 1);
say_stop("`0maybe. I saw a guy with blue clothes for some minuttes ago", &karl);
say_stop("Ok?", 1);
say_stop("`0I saw him with a famer ", &karl);
say_stop("where did he go", 1);
say_stop("`0I don`t know", &karl);
say_stop("Ok thanks", 1);
unfreeze(1);
unfreeze(&karl);
}
if (&result == 2)
{
freeze(1);
freeze(&karl);
say_stop("Hi what is your name?", 1);
say_stop("`0My name is Carl", &karl);
unfreeze(1);
unfreeze(&karl);
}
}
So try:
void main( void )
{
int &karl = create_sprite(290, 230, 16, 381, 1);
sp_speed(&karl, 2);
sp_base_walk(&karl, 380);
preload_seq(381);
preload_seq(383);
preload_seq(385);
preload_seq(387);
preload_seq(389);
}
void talk(void)
{
freeze(&karl);
freeze(1);
choice_start()
"have you seen a guy named David"
"who are you"
"nevermind"
choice_end()
unfreeze(1);
unfreeze(&karl);
if (&result == 1)
{
freeze(1);
freeze(&karl);
say_stop("have you seen a guy named David", 1);
say_stop("`0maybe. I saw a guy with blue clothes for some minuttes ago", &karl);
say_stop("Ok?", 1);
say_stop("`0I saw him with a famer ", &karl);
say_stop("where did he go", 1);
say_stop("`0I don`t know", &karl);
say_stop("Ok thanks", 1);
unfreeze(1);
unfreeze(&karl);
}
if (&result == 2)
{
freeze(1);
freeze(&karl);
say_stop("Hi what is your name?", 1);
say_stop("`0My name is Carl", &karl);
unfreeze(1);
unfreeze(&karl);
}
}
Nope its not that, I tried it before I submitted the post

But that doesn't mean you should just place the brackets where you please
Also, you should place the freeze commands only in the beginning and only unfreeze at the end, and not after a choice menu and in every option. That way it's easier to keep track of what happens when the player might press space to skip a conversation.
And.. I'm still a bit sleepy I see
That void talk(void) is the talk procedure of the sprite that the script's attached to. So if you go to the sprite you created, he won't talk because he doesn't have a script attached. If you want him to talk, you should attach a script to him and in that script, you should place talk, hit, etc

Also, you should place the freeze commands only in the beginning and only unfreeze at the end, and not after a choice menu and in every option. That way it's easier to keep track of what happens when the player might press space to skip a conversation.
And.. I'm still a bit sleepy I see


Yes, the sprite we're created in another script and it had the talk procedure in another script, but that made it buggy for Dink v1.08, but I'll try once more.
EDIT
Script #1
void main( void )
{
int &karl = create_sprite(290, 230, 16, 381, 1);
sp_speed(&karl, 2);
sp_script(&karl, g2);
sp_base_walk(&karl, 380);
preload_seq(381);
preload_seq(383);
preload_seq(385);
preload_seq(387);
preload_seq(389);
}
Script #2
void talk(void)
{
freeze(&karl);
freeze(1);
choice_start()
"have you seen a guy named David"
"who are you"
"nevermind"
choice_end()
unfreeze(1);
unfreeze(&karl);
if (&result == 1)
{
freeze(1);
freeze(&karl);
say_stop("have you seen a guy named David", 1);
say_stop("`0maybe. I saw a guy with blue clothes for some minuttes ago", &karl);
say_stop("Ok?", 1);
say_stop("`0I saw him with a famer ", &karl);
say_stop("where did he go", 1);
say_stop("`0I don`t know", &karl);
say_stop("Ok thanks", 1);
unfreeze(1);
unfreeze(&karl);
}
if (&result == 2)
{
freeze(1);
freeze(&karl);
say_stop("Hi what is your name?", 1);
say_stop("`0My name is Carl", &karl);
unfreeze(1);
unfreeze(&karl);
}
}
this made it buggy and Carl would still not talk.
EDIT
Script #1
void main( void )
{
int &karl = create_sprite(290, 230, 16, 381, 1);
sp_speed(&karl, 2);
sp_script(&karl, g2);
sp_base_walk(&karl, 380);
preload_seq(381);
preload_seq(383);
preload_seq(385);
preload_seq(387);
preload_seq(389);
}
Script #2
void talk(void)
{
freeze(&karl);
freeze(1);
choice_start()
"have you seen a guy named David"
"who are you"
"nevermind"
choice_end()
unfreeze(1);
unfreeze(&karl);
if (&result == 1)
{
freeze(1);
freeze(&karl);
say_stop("have you seen a guy named David", 1);
say_stop("`0maybe. I saw a guy with blue clothes for some minuttes ago", &karl);
say_stop("Ok?", 1);
say_stop("`0I saw him with a famer ", &karl);
say_stop("where did he go", 1);
say_stop("`0I don`t know", &karl);
say_stop("Ok thanks", 1);
unfreeze(1);
unfreeze(&karl);
}
if (&result == 2)
{
freeze(1);
freeze(&karl);
say_stop("Hi what is your name?", 1);
say_stop("`0My name is Carl", &karl);
unfreeze(1);
unfreeze(&karl);
}
}
this made it buggy and Carl would still not talk.
try replacing:
sp_script(&karl, g2);
with:
sp_script(&karl,"g2");
sp_script(&karl, g2);
with:
sp_script(&karl,"g2");
I'll try tonight when im not lazy
In addition, you'd now need to refer to the sprite as ¤t_sprite in Script #2 as that's the sprite the script's attached to

You mena løike &karl = ¤t_sprite; ?
Er, um... yes, sorta
I think I know what you want, but I'm not sure; I need to get off my butt and learn DinkC
I think I know what you want, but I'm not sure; I need to get off my butt and learn DinkC

It was just the way I did before I started editing the script lol. Maybe I shouldn't use create sprite

Yeah... if you place the sprite on the map in Dinkedit, just attach a script to it and don't worry about any create sprite crap. And again, if you're going to do that, you'd use ¤t_sprite instead of &karl.
I know, but this was the first D-Mod I created when I learned using create_sprite and the Global Variables.
