Question about different dialogs...

Started by KillerKlown, Tue 21/11/2006 18:44:36

Previous topic - Next topic

KillerKlown

Hi...i just need an answer to this...i read a tutorial about variables. It contained something with my_counter etc. I want to be able to have different dialogs run after i've done things in the game...let's say...when i initially talks to a guy, dialog 1 starts, and let's say i pick up an object later on...should i add 1 to my_counter in that room where i got the object?

When i return to the room with the guy the script would have something like "if (my_counter == 1) {
should i add "run dialog 2" or?...hope you know what i mean hehe...my english isn't perfect

Ghost

Two methods are possible here.

You can change a global variable depending on actions the player does, and in the TALK TO option for the target character, you'd include something like your above IF GLOBAL_VAR == 1...

Or, you could just switch dialog topics on and/or off, instead of changing the whole dialog. This would be more handy if a certain action changes only some parts of a dlg, though.

As for the scripting, you're right. The action should change the global variable. Code from other objects should refer to that variable. That way, you can be sure that you can access the var from everywhere in the game, and read it from everywhere too.

BTW your english really isn't that bad  ;)

KillerKlown

Hehe well i've studied the english language for some time...

ok i haven't tried turning on/off options but...if i get...a book for example and
return to the guy...how do i change to turn dialog options on..."if player got inventory item" turn on dialog option "3" or?

Ghost

Dialog.GetOptionState and Dialog.SetOptionState are the commands you'll want to use; just browse the manual for them.

Candle


KillerKlown

Quote from: Candle on Tue 21/11/2006 21:01:17
And turn them on and off in other rooms with the MODULE: OtherRoom v0.85
http://www.adventuregamestudio.co.uk/yabb/index.php?topic=20650.0
ah nice...thanks guys i'll look into this :D

strazer

Thanks Candle for plugging the module, but they're not talking about room objects but dialog options, which are accessible globally anyway.

Khris

#7
KillerKlown:
To introduce a global variable, declare and export it at the start of the global script, outside any funtion:
Code: ags
int my_counter=1;
export my_counter;

Then import it in the script header:
Code: ags
import int my_counter;

In the interaction where the books gets picked up, use
Code: ags
my_counter++;   // increment variable by one

In the character's talk to interaction, use something like
Code: ags
if (my_counter==1) dNobookyet.Start();
else dGotbook.Start();

(Nobookyet and Gotbook are just examples of names for the dialogs.)


Claaaus

@ KhrisMUC
Your post from 21 Nov 2006 was really helpful to me. I had the same problem as KillerKlown and your answer led me straight to the point. Thanks, mate!

Dualnames

No need to post after a year when you can PM him...
Worked on Strangeland, Primordia, Hob's Barrow, The Cat Lady, Mage's Initiation, Until I Have You, Downfall, Hunie Pop, and every game in the Wadjet Eye Games catalogue (porting)

SMF spam blocked by CleanTalk