The Dink Network

Talking

May 7th 2005, 09:21 AM
dragon.gif
i have asked this before but... HOW do you make things talk? i am new to scrpting so i need some help.

if you shall help, make an example.

please...
May 7th 2005, 09:54 AM
fish.gif
Simeon
Peasant He/Him Netherlands
Any fool can use a computer. Many do. 
If you want Dink to talk, do:

say("text", 1);
or:
say_stop("text", 1);

The difference is that the first one lets Dink say it and the second one pauses the script: it waits before doing the next line (and the player can skip by pressing spacebar).

If you want the sprite the script is attached to say something, do:

say("text", &current_sprite);
or:
say_stop("text", &current_sprite);

If you want any sprite on the screen to say something, use:

int &crap = sp(xx);
say("text", &crap); (or say_stop)

where xx is the number of the sprite in the editor.

Now, in a script, it would need to be in the void talk(void) part to make it work when Dink presses spacebar:

void talk(void)
{
freeze(1)
freeze(&current_sprite)
say_stop("Hello", 1);
wait(250);
say_stop("`6Heya!", &current_sprite);
wait(250);
say_stop("Bye", 1);
unfreeze(1)
unfreeze(&current_sprite)
}
May 7th 2005, 10:09 AM
pq_skull.gif
dinkme
Peasant He/Him India
 
Make sure that the files you are attaching to the sprite or screen are of .c type not of text document.
May 7th 2005, 10:11 AM
dragon.gif
does that work with windink? i have checked the Tut1 in the "develop" and found something i never seen before, i saw the thing about how to make a tree say ouch when you hit it, the script was like this

void hit(void)
{
say("`4Ouch!", current_sprite);
}

i wanted to a guy that in my story shall have the name johnny should say that, so i made a text document that had the name "johnny" and i attached it to johnny and...

it didnt work... do i need to use the dinkc program?
May 7th 2005, 10:12 AM
dragon.gif
hey dinkme, you said that when i was writing...

so much text for nothing...
May 7th 2005, 10:33 AM
dragon.gif
i got it! and how do you make people sell things, then?
May 7th 2005, 10:58 AM
fish.gif
Simeon
Peasant He/Him Netherlands
Any fool can use a computer. Many do. 
Selling things takes a bit more script as you need to check if people have enough cash, enough room in their inventory and such. A working sell script would be:

void talk(void)
{
freeze(1)
freeze(&current_sprite)
choice_start()
set_y 240
set_title_color 5
title_start();
Shop Text

Blaaa
title_end();
"Buy elixer for 100 gold"
"Leave"
choice_end()
wait(300);

if (&result == 1)
{
if (&gold < 100)
{
say_stop("`5Sorry, not enough gold..", &current_sprite);
goto leave;
}
int &junk = free_items();
if (&junk < 1)
{
say_stop("`5Sorry, you're carrying too much", &current_sprite);
goto leave;
}
add_item("item-eli",438,9);
&gold -= 100;
}

leave:
unfreeze(&current_sprite)
unfreeze(1)
}

But then, usually your shop has a guy behind the counter so it's slightly different because not the &current_sprite would be talking/selling but a sprite behind the counter. I'd say look at some salescripts from the original game, they can be found in the develop directory in the source.zip file.
May 7th 2005, 11:03 AM
dragon.gif
okay
May 7th 2005, 11:10 AM
dragon.gif
i got one problem...
i have made a script that looks like this

void talk(void)
{
freeze(1)
freeze(¤t_sprite)
say_stop("hi, johnny!", 1);
wait(250);
say_stop("`3mmmm.....", ¤t_sprite);
wait(250);
say_stop("are you reading newspaper?", 1);
wait(250);
say_stop("`3It's about the army...", ¤t_sprite);
wait(250);
say_stop("AGAIN?!? THEY ALWAYS TALK ABOUT THE ARMY!!", 1);
wait(250);
say_stop("`3HEY,Calm down!!", ¤t_sprite);
wait(250);
say_stop("grmmmbl... no real news nowadays... grrrrmbl..., 1);
wait(250);
say_stop("`3OH LOOK! The army will be here today 12 o' clock at the mushroom farm!, ¤t_sprite);
wait(250);
say_stop("Thats now!, 1);
wait(250);
say_stop("`3Lets go then!", ¤t_sprite);
wait(250);
unfreeze(1)
unfreeze(¤t_sprite)
}

but when johnny says "HEY,Calm down!" he jumps directy to say "lets go then!" so every logic in the talk dissapear! what is wrong?

and by the way, what is the name of the shop script in the first town?
May 7th 2005, 11:11 AM
fish.gif
Simeon
Peasant He/Him Netherlands
Any fool can use a computer. Many do. 
That's because several ending " are missing.

Edit: s2-healp.. for the elixers selling script.
May 7th 2005, 11:16 AM
dragon.gif
i mean the script for sword and stuff.
May 7th 2005, 01:03 PM
goblinm.gif
You can drop those wait(250) statements if you want, and allow people to spacebar through.
May 7th 2005, 01:43 PM
dragon.gif
my d-mod is begining to look like something, after two years of trying, i have got it! (thanks to windink!)

just two more things, i need someone to move after a few things have happened, like the knight standing in the way at stonebrook,
and dink and johnny (look on this post and you see that johnny and dink shall go and check the army out) shall go to a muschroom farm after he said a few things and then there shall be a few knights and such but they shall not be there in the beginning. how do you do that?
May 7th 2005, 01:56 PM
fish.gif
Simeon
Peasant He/Him Netherlands
Any fool can use a computer. Many do. 
Visions. Place the knight (and if needed, some blocking sprites) in a vision, like vision 1, and attach a script to the screen (press B) where you control the vision (&story <= 3 can be whatever you have):

void main(void)
{
if (&story <= 3)
{
&vision = 1;
}
}
May 7th 2005, 03:11 PM
dragon.gif
well, it dosent work.
i have placed 6 knights, one golden knight and a catapult, attached the script to the screen and it dosent work. and i have tried edit the vision of the screen to one.

but it wont work...

void main(void)
{
if (&story <= 3)*1
{
&vision = 1;
}
}

*1 shall there be a script name here as i want the knights to be seen AFTER my "johnny" script has ben used?

May 7th 2005, 03:47 PM
fish.gif
Simeon
Peasant He/Him Netherlands
Any fool can use a computer. Many do. 
Well, you'll need to put the objects in vision 1 in this case. Then the variable controls when it'll display that vision. So if the knights are there when &story is 0, 1 and 2, you should make it if (&story <= 2). Or if they're only there when &story is 3, then you should make it if (&story == 3). Basically variables control the state of the game and when something happens, you need to change a variable to keep track of it. Usually &story is the main variable throughout the game but you can use other variables as well for subquests or other things that need to be tracked.
May 8th 2005, 12:27 AM
pq_skull.gif
dinkme
Peasant He/Him India
 
Read the rudiments of scripting, that will clearify all the statements you need to create a simple DMod
May 8th 2005, 02:13 AM
dragon.gif
it still won't work!
i have made a global that looks like this
make_global_int("&story",0); and i have made the story to go on like this
void talk(void)
{
freeze(1)
freeze(¤t_sprite)
if (&story == 0)
if(&story==0)
say_stop("Hello, mother", 1);
wait(250);
say_stop("`5hello darling, what about going to johnny?", ¤t_sprite);
wait(250);
say_stop("Great idea! Bye mum!", 1);
wait(250);
say_stop("`5remember to come home for dinner!", ¤t_sprite);
wait(250);
&story = 1;
unfreeze(1)
unfreeze(¤t_sprite)
}
}
but here when they talk dink can walk around because it wont freeze...

and this

void talk(void)
{
freeze(1)
freeze(¤t_sprite)
if (&story == 1)
say_stop("hi, johnny!", 1);
wait(250);
say_stop("`3mmmm.....", ¤t_sprite);
wait(250);
say_stop("are you reading newspaper?", 1);
wait(250);
say_stop("`3It's about the army...", ¤t_sprite);
wait(250);
say_stop("AGAIN?!? THEY ALWAYS TALK ABOUT THE ARMY!!", 1);
wait(250);
say_stop("`3HEY,Calm down!!", ¤t_sprite);
wait(250);
say_stop("grmmmbl... no real news nowadays... grrrrmbl...", 1);
wait(250);
say_stop("`3OH LOOK! The army will be here today 12 o' clock at the mushroom farm!", ¤t_sprite);
wait(250);
say_stop("Thats now!", 1);
wait(250);
say_stop("`3Lets go then!", ¤t_sprite);
wait(250);
&story = 2;
unfreeze(1)
unfreeze(¤t_sprite)
} and here he can walk around too...
and when i attach theese to the mother and johnny they can talk but the knights in the screen with this script can still be seen even if i havent talked to the mother and johnny...
void main(void)
{
if (&story <= 2)
{
&vision = 1;
}
}

as you shall not see the knights untill the story is 2 and as i can see them anytime even
when the story still is 0,
i wonder, WHAT IS WRONG!?
May 8th 2005, 04:07 AM
spike.gif
First problem: you're missing a ton of brackets and ; after freeze(1) and freeze(&current_sprite)
like this:
freeze(1);
unfreeze(&current_sprite);

Second problem: if (&story <= 2) stands for "if story is 2 or less than 2"
it's simple math.
< means less than
> means more than
= means the same as

if you want the knights to appear only when the story is 2, you use
if (&story == 2) why you need two ==, I don't know, it's a c thing. but you do.

if you want them to appear when the story is 2 or more, you can use
if (&story >= 2)
or
if (&story > 1)
May 8th 2005, 02:42 PM
dragon.gif
now theese things is fixed, the only thing left so dink can get off the bloody ice island in my d-mod, it's another script problem.

void talk(void)
{
if (&story == 2)
freeze(1)
freeze(&current_sprite)

choice_start();
"Hello"
"you have a big nose"
(&story == 2) "how do i join the army?"
"Leave"
choice_end();

if (&result == 1)
{
say_stop("Hello, cap'n, did any klling nowadays?", 1);
wait(250);
say_stop("`4SHUT UP! Were trying to save our country, as you cowards wont!", &current_sprite);
wait(250);
say_stop("hey, watch out, you might rust!", 1);
wait(250);
say_stop("`4 do you think my armor is my life!?", &current_sprite);
wait(250);
say_stop("actually, yes.... he he...", 1);
wait(250);
}

if (&result ==2)
{
say_stop("You have a veeery large nose!", 1);
wait(200);
say_stop("`4 do you know how sharp my axe is???", &current_sprite);
}

if (&result == 3)
{
if (&story == 3)
{
say_stop("Hey im off for an adventure, how to join the army?", 1);
wait(250);
say_stop("`4well, our camp is down the river over a bridge, get there and you can join.", &current_sprite);
wait(250);
say_stop("well, is it much wine song and womens?", 1);
wait(250);
say_stop("`4*suddenly quiet*", &current_sprite);
wait(250);
say_stop("`4eerrr... well... n- yes of course!", &current_sprite);
wait(250);
say_stop("Well, then im in!!", 1);
&story = 3;wait(250);
say_stop("`4by the way, If you shall join our army, you should get a sword.", &current_sprite)
wait(250);
say_stop("`4i think i heard that there were money in the monasterys catacombs, maybe you should check it...", &current_sprite);

&story = 3;
}
}

unfreeze(1)
unfreeze(&current_sprite)

it jumps over "you have a veeeery large nose!"
and you can only choose one of all 3 questions
and when you choose the only working question (hello) everything (exept you have a big nose)
is said... i ask again, what is wrong?
May 8th 2005, 03:12 PM
fish.gif
Simeon
Peasant He/Him Netherlands
Any fool can use a computer. Many do. 
Well, you need to work on the brackets. Your first if (&story == 2) doesn't have a { bracket and it also doesn't have a close bracket. Your void talk(void) also lacks a closing bracket. Then you need to check when it should display what choice menu options or parts in the script. For example, your third menu option now only shows up when &story is 2 yet when the player selects it, it checks if &story is 3 and if that isn't the case, nothing is said so that menu option can't work. Also, it makes &story 3 if it is already 3..
May 8th 2005, 03:29 PM
dragon.gif
i dont understand what you mean with close bracket and such, can't you just rewrite it and show how it shall be?

i dont mean im too lazy to do it myself, i just want to see how it looks...

please...

or just tell and show what closing bracets and such is...
May 8th 2005, 03:50 PM
goblinm.gif
Open bracket is {
Closed bracket is }
May 8th 2005, 03:52 PM
dragon.gif
ok, thanks, know i know something, by the way, how long does a d-mod romp to complete?
May 8th 2005, 03:53 PM
dragon.gif
ok, thanks, know i know something, by the way, how long does a d-mod romp to complete?

(oops double!)
May 8th 2005, 04:08 PM
goblinm.gif
Brackets separate a piece of code that you only want to run under certain circumstances.
Examples:

void main( void )
{
if (&story == 1)
{
//stuff inside these brackets is run if &story is 1
say("look, a tree", 1);
}
if (&love == 1)
{
//stuff inside these brackets is run if &love is 1
say("I am in love", &current_sprite);
}
}

This will make the sprite say "I am in love" if &love is 1 and make dink say "look, a tree" if &story is 1. These events are independent, each happens regardless of whether the other happens. Why are the brackets neccesary? Because there would be another way to parse these statements if there were no brackets. Observe:

void main( void )
{
if (&story == 1)
{
say("look, a tree", 1);
if (&love == 1)
{
say("I am in love", &current_sprite);
}
}
}

Now, dink will say "look, a tree" if &story is 1, and the sprite will say "I am in love" if &love is 1 AND &story is 1, because the second if statement will not be reached unless &story is 1.

If this is confusing, here are some rules.

1.For every open bracket, there is a closed bracket.

2.Procedures, like void main( void ) or main talk( void ) require brackets (don't ask me why ). For example, this is good:

void main( void )
{
say("this is where the stuff goes", 1);
}

But this is bad:

void main( void )
say("This doesn't go here!", 1);
{
}

And this is bad

void main( void )
{
void talk( void )
{
}
}

But this is good:
void main( void )
{
}
void talk( void )
{
}

3.If statements require brackets, for reasons already explained.
May 8th 2005, 04:58 PM
fish.gif
Simeon
Peasant He/Him Netherlands
Any fool can use a computer. Many do. 
Procedures, like void main( void ) or main talk( void ) require brackets (don't ask me why )

Well, basically for the same reasons as why you normally use brackets: to indicate the beginning and the end of a piece of code

And dinkdragon, I'll remember to explain it in a different way next time

...how long does a d-mod romp to complete?

D-Mod Romp: A small D-Mod that generally takes less than an hour to beat
May 8th 2005, 05:06 PM
goblinm.gif
It's hard to think of an example in DinkC where removing the procedural braces would create ambiguities. On the other hand, I can think of a lot of examples of that with C++, so...
May 9th 2005, 12:32 AM
dragon.gif
i mean to MAKE a d-mod!
May 9th 2005, 12:43 AM
dragon.gif
something like this?

void talk(void)
{
}
if (&story == 2)
{
freeze(1)
freeze(&current_sprite)
}
choice_start();
"Hello"
"you have a big nose"
(&story == 2) "how do i join the army?"
"Leave"
choice_end();

if (&result == 1)
{
say_stop("Hello, cap'n, did any klling nowadays?", 1);
wait(250);
say_stop("`4SHUT UP! Were trying to save our country, as you cowards wont!", &current_sprite);
wait(250);
say_stop("hey, watch out, you might rust!", 1);
wait(250);
say_stop("`4 do you think my armor is my life!?", &current_sprite);
wait(250);
say_stop("actually, yes.... he he...", 1);
wait(250);
}

if (&result ==2)
{
say_stop("You have a veeery large nose!", 1);
wait(200);
say_stop("`4 do you know how sharp my axe is???", &current_sprite);
}

if (&result == 3)
{
if (&story == 3)
}
{
say_stop("Hey im off for an adventure, how to join the army?", 1);
wait(250);
say_stop("`4well, our camp is down the river over a bridge, get there and you can join.", &current_sprite);
wait(250);
say_stop("well, is it much wine song and womens?", 1);
wait(250);
say_stop("`4*suddenly quiet*", &current_sprite);
wait(250);
say_stop("`4eerrr... well... n- yes of course!", &current_sprite);
wait(250);
say_stop("Well, then im in!!", 1);
&story = 3;wait(250);
say_stop("`4by the way, If you shall join our army, you should get a sword.", &current_sprite)
wait(250);
say_stop("`4i think i heard that there were money in the monasterys catacombs, maybe you should check it...", &current_sprite);
}
{
&story = 3;
}
{
unfreeze(1)
unfreeze(&current_sprite)
}
May 9th 2005, 02:04 AM
pq_skull.gif
dinkme
Peasant He/Him India
 
Plenty of errors:
This should be like this

void talk(void)
{
//don't close the bracket here
//close it when all the things
//in the talk function are done
if (&story == 2)
{
freeze(1)

freeze(&current_sprite)
//here the same mistake
//close it after what will happen when story is
//2 is done
choice_start();
"Hello"
"you have a big nose"
(&story == 2) "how do i join the army?"
"Leave"
choice_end();

if (&result == 1)
{
say_stop("Hello, cap'n, did any klling nowadays?", 1);
wait(250);
say_stop("`4SHUT UP! Were trying to save our country, as you cowards wont!", &current_sprite);
wait(250);
say_stop("hey, watch out, you might rust!", 1);
wait(250);
say_stop("`4 do you think my armor is my life!?", &current_sprite);
wait(250);
say_stop("actually, yes.... he he...", 1);
wait(250);
}

if (&result ==2)
{
say_stop("You have a veeery large nose!", 1);
wait(200);
say_stop("`4 do you know how sharp my axe is???", &current_sprite);
}

if (&result == 3)
{
if (&story == 3)
//why did you close the bracket here?
{
say_stop("Hey im off for an adventure, how to join the army?", 1);
wait(250);
say_stop("`4well, our camp is down the river over a bridge, get there and you can join.", &current_sprite);
wait(250);
say_stop("well, is it much wine song and womens?", 1);
wait(250);
say_stop("`4*suddenly quiet*", &current_sprite);
wait(250);
say_stop("`4eerrr... well... n- yes of course!", &current_sprite);
wait(250);
say_stop("Well, then im in!!", 1);
&story = 3;wait(250);
say_stop("`4by the way, If you shall join our army, you should get a sword.", &current_sprite)
wait(250);
say_stop("`4i think i heard that there were money in the monasterys catacombs, maybe you should check it...", &current_sprite);
&story = 3;
}
}
unfreeze(1)
unfreeze(&current_sprite)
}

Time to make a Dmod romp- Depends upon your laziness
May 9th 2005, 03:05 AM
spike.gif
It completely depends.
May 9th 2005, 08:28 AM
fish.gif
Simeon
Peasant He/Him Netherlands
Any fool can use a computer. Many do. 
Yes but then still certain menu items won't work. The whole thing now only works when &story is 2. The third menu item only shows when &story is 2 but that has been checked before so there's no need to check it again. Then, if the user selects that menu option (the third), &result is 3 and there, it checks if &story is 3 but that's not even possible because then the first if-statement (if (&story == 2)) would have returned false. Also, making &story equal to 3 in case it is 3 isn't very handy. You probably need to check what value &story needs to have when a certain event/question has been done/said/asked and then fix the if-statements