Add Dialog Options

Started by , Wed 02/07/2003 18:08:52

Previous topic - Next topic

Plog

Is there a way I can have it so once I have talked to a charcter about a certain topic that I can make it add an extra option to his dialog?
Kepp it as simple as you can im a serious newbie.

SSH

#1
Quote from: Plog on Wed 02/07/2003 18:08:52
Is there a way I can have it so once I have talked to a charcter about a certain topic that I can make it add an extra option to his dialog?

To turn an option on, you put option-on option number in your dialog script. You know, if you read the tutorial in the Help menu, you can find these things out without having to connect to the internet!

Also, you don't need to start a new thread in the forums to ask the same question in a slightly different way. Just reply to the exisinting thread.
12

Plog

Sorry I told you I was a newbie but my internet is allways connected soo... yeah. thanks by the way.

Plog

I forgot to say the dialog he talks in is different from the one I want to add one in how do I do that.

SSH

#4
No problems. Welcome to using AGS. If you make a really good game, please let us know! Please do read the manual, though!

The thing to remember, as it says in the Beginners forum rules, (which I'm sure that you read before posting  ::) ) Chris Jones, the guy who wrote AGS and lets us have it for free and keeps adding great new features, has to pay for bandwidth used by this site, so it's kinda rude to spend his money on something that you could have found out in the program itself.

On the other hand, if you look at some of the rubbish in the other forums...  ;)

EDIT:
Oh, and you can edit replies to add things or fix mistakes, rather than post multiple one-liners.

To reply to your question about if the option is in a nother topic: well:

1) Does it really need to be another topic?
2) This is a bit mor tricky. You''l need to use:

run-script X        


which runs global text script function "dialog_request", with X passed as the single parameter.

 function dialog_request (int xvalue) {
   if (X==1) {
SetDialogOption (int topic, int option, int new_state);
   }
 }
 

12

Plog

 :o
Oh I dont get that.
Where exactly do I put it and where do I put the number from which dialog its from and number of option.

Thanks for the welcome. But I could never make a good game Im just re-making one I drew on paper once a while back.

Wolfgang Abenteuer

The run-script x line goes under the dialog option you want to have run the script, e.g.:

@S
@1
ego: "Hello"
run-script 1
@2
stop

and the function dialog_request (int x1) { plus the code that SSH gave you goes at the end of your global script.

~Wolfgang

Plog

I put it in and it told me to reaplace the X.
function dialog_request (int x1) {
if (X==1) {
SetDialogOption (int topic, int option, int new_state);
}
}
And that there is a Parse error expr near 'int'
on the setdialog line.
Man this is confusing me.

Wolfgang Abenteuer

You need to replace "topic" with the topic number you are referring to, "option" with the dialog option you want to change, and "new_state" with "0" of you want to make the option disappear, "1" if you want to make the option appear, or "2" if you want to make it disappear forever.

So, if you wanted topic #1's dialog option #3 to appear with that code, for example, you'd write:

SetDialogOption (1, 3, 1);

~Wolfgang

Plog

What do I change the X to though. An what does the int x1 bit mean?

Wolfgang Abenteuer

You mean the "X==1" or the "x1"?  The "X==1" line that SSH posted means that the variable "X" has to be exactly "1" or else the code will not run.

The "int x1" in the "function dialog_request" line refers to the "run-script 1" line you put in the dialog script.  Had you put "run-script 2", then you would have needed "int x2" instead of "int x1".

~Wolfgang

Plog

Two more questions.
1) It wont accept the X in (X==1) what do I do?

2) How do I make it that a option dosn't show up until that dialog happens?

Wolfgang Abenteuer

#12
In order for it to accept the X==1 you need to first declare "X" as an variable by adding int x;.

If you're just using the function as a dialog on/off type function, it might be easier to use GlobalInts rather than normal variables, otherwise you'd have to do variable importing and exporting to be able to access those variables in your global script from local room scripts, whereas GlobalInts take care of that for you.

That might go like this:

(Topic 0)
@S
return
@1 //greet
salesman1: "Hello!"
ego: "I'd like to buy something."
return
@2 //buy steak
salesman: "I don't sell steak, talk to the other salesman."
run-script 1
return
@3
stop

Then at the end of the global script:
function dialog_request (int xvalue) {
if (value == 1)
 SetGlobalInt (0, 1);
}

Finally, in the "talk to character" script for the second salesperson, select "run script", then add the code:

if (GetGlobalInt(0) == 1) {
 SetDialogOption (1, 3, 1);
}
else {
 SetDialogOption (1, 3, 0);
}

Then, the second character's dialog (Topic 1) will look like this:

<Greet> // option 1
<Buy Coffee> // option 2
<Buy Steak> // option 3--will be hidden if the player hasn't asked the first salesperson about "Steak".

~Wolfgang

Plog

Can you tel me what all the numbers stand for.
Because I am seriously bad at this.

Wolfgang Abenteuer

My best advice would be to check the Help file in the AGS program.  It lists all of the available functions as well as what all the "int"s represent.  Also, you might want to take a look at the short scripting tutorial (also in the AGS help file) which shows you the basics of assigning variables, if/else statements, GlobalInts, and such.  It can help you get started with AGS scripting.

~Wolfgang

TerranRich

All this run-script stuff is covered in the Beginners' FAQ. Have you even tried looking there, Plog? :)
Status: Trying to come up with some ideas...

Plog

Can you just please tell me what each number means becuase Ive searched I cant find anything on this please I beg of you. ???

Wolfgang Abenteuer

The SetDialogOption numbers are (int topic, int option, int new_state).

int topic is the topic number of the topic you wish to modify with the script.  You can find this number in the Dialogs tree tab in AGS.

int option is the option number of the topic you selected that you wish to change.  This is also found in the Dialogs tree tab.

int new_state tells AGS whether to turn the option on, off, or off forever.  0 would turn the option off, 1 would turn the option on, and 2 would turn the option off forever.

So, SetDialogOption(0,3,1); would turn on option number 3 in topic 0.

The SetGlobalInt numbers represent the number of the GlobalInt and the value to which it is set.

So SetGlobalInt(0, 1); would set GlobalInt #0 to the value of 1.

The GetGlobalInt numbers check a GlobalInt and see if it is set to a certain value.

GetGlobalInt(0) == 1; checks to see if GlobalInt #0 is equal to 1.

By the way, the AGS help file has a contents index sorted by function.  If you see someone mention GetGlobalInt, for example, then go to the AGS Help menu, click the "Index" tab, then type in GetGlobalInt in the box and press Enter and it will display the function, its parameters, and its usage.  Nearly all of the information you need to successfully use every feature of AGS is in that file.

~Wolfgang

Plog

Thanks but what is this bit for wouldnt this turn it off again?

}
else {
SetDialogOption (1, 3, 0);
}

Wolfgang Abenteuer

Sort of.  The "else" means that if GlobalInt 0 is anything other than "1", then the dialogue option will be turned off.  As long as the value of GlobalInt 0 stays at 1, the option will be turned on.  The "else" part just ensures that the option will never come on unless GlobalInt 0 is 1.  That's to prevent the option from staying on if you decide to hide it again later.  Once a dialogue option has been turned on with code, it can only be turned off again with code.  That's what the "else" is for.

If you never plan on changing GlobalInt 0 back to 0 or any other number afterwards, then the "else" line isn't necessary.  I always put one in my scripts just for good measure, though. ;)

~Wolfgang

SMF spam blocked by CleanTalk