Setting variables in the dialog script. [SOLVED]

Started by , Fri 04/03/2005 22:32:13

Previous topic - Next topic

Anon.

Is it possible to set a variable's value to something else in the dialog script?
I think it might look like this.

option 1 clicked
EGO: Hello
SetVariableValue (Variable1, 2)

Something like that but I don't know what script to type, where to put it or if it's possible.

LazyAshen

You can set GlobalInts using set-globalint GI VAL (e.g. set-globalint 5 3). To set other variables, or do anything not directly supported in dialogs, you need to look up run-script x and dialog_request, which is explained in the BFAQ.

Anon.

What if I have scriptophobia and need people to tell me EXACTLY what to do and EXACTLY what script to write?

Anon.

I just realised that I haven't actually said what I need to do in the game I'm making. In my game, I want the following things to happen. When you choose a specific dialog option and click on it. Not only will the character say the words, it will also change a variable's value to 2.

Ashen

#4
Quote from: Anon. on Fri 04/03/2005 22:53:54
need people to tell me EXACTLY what to do

Do you know how tempting that is?
I'm faily sure this is all in the manual, whcih you really should've read. Anyway, to reiterate:
If you want to set a Global Int, use set-globalint GI VAL, e.g.:

option 1 clicked
EGO: Hello
set-globalint 1 2

If you want to use an int you created yourself, you need to use run-script x and dialog_request which is explained in the BFAQ. Note how the words "in the BFAQ" are actually a link, taking you to the place in the BFAQ that explains run-script x and dialog_request. It also explains creating your own variables. That's about as detailed as I can get, without knowing what variable you want to change.
Ah, what the heck:

option 1 clicked
EGO: Hello
run-script 1

Then, insert this somewhere in the global script (unless it already exists):
Code: ags

function dialog_request(int param) {
  if (param==1) {
    Variable1 = 2;
  }
}
I know what you're thinking ... Don't think that.

Freydall

Formally 'Anon.'...

Thanks a bunch (not sarcastic)
It works now.
AEscplega is the best epic ever. Chapter I is finally finished and Chapter II is on it's way.

SMF spam blocked by CleanTalk