I've found a few posts dealing with this topic, but they seem to be around 6 years old, and haven't been much help, so I'm going to ask here. Apologies if this is redundant.
In Gabriel Knight, options in dialogs were often activated by finding a certain object or hearing a phrase from someone else. If you found a snake scale, you could ask someone about snake scales during a dialog with them, whereas that option would not be available if you had not found a snake scale.
How does one do that in scripting? For example, there is a painting in a house. The player cannot ask about the painting in a dialog unless he has looked at the painting.
So I set a global variable called "painting". When the player looks at the painting, it sets the "painting" variable to 1.
This is what I *want* to write in the dialog script:
@S
if (painting == 1)
{
option-on 3
}
However, that doesn't work, because its mixing the dialog scripting and regular scripting all together.
How would one go about doing it? Am I looking at it the wrong way? It seems like it should be simple...
In contemporary version of AGS dialogs may contain AGS script,
Quote from: AGS Manual
Conversations
While the old Sierra games were mainly based on action and not talking, the Lucasarts games took the opposite approach. ...
:
:
:
AGS now lets you put normal scripting commands in your dialog script, by indenting the line with spaces or tabs. For example:
@1
ego: "Hello. How are you?"
narrator: The man looks you in the eye.
player.AddInventory(iKey);
Display("This line is displayed from a normal script command");
otherman: "I'm fine."
return
:
:
ego: "Hello. How are you?"
narrator: The man looks you in the eye.
if (player.HasInventory(iKey)) {
player.Say("Actually, I'd better go.");
return RUN_DIALOG_STOP_DIALOG;
}
otherman: "Here's a key for you."
return
Your example doesn't work because you put a dialog instruction into an AGS script code block. You should have used the script function SetOptionState(..) instead.
Quote from: AGS Manual
SetOptionState (dialog)
(Formerly known as global function SetDialogOption, which is now obsolete)
Dialog.SetOptionState(int option, DialogOptionState)
Changes whether an option in a conversation is available to the player or not. This allows you to add extra options to a conversation once the player has done certain things.
OPTION is the option number within the topic, from 1 to whatever the highest option is for that topic.
The DialogOptionState controls what happens to this option. It can have the following values:
eOptionOff
The option is disabled - the player will not see it
eOptionOn
The option is enabled - the player can now see and use it
eOptionOffForever
The option is permanently disabled - no other command can ever turn
it back on again.
Btw, use of a global variable can be eliminated by calling SetOptionState(..) from your script instead of setting a global variable.
thanks RickJ! Everything's working great now. :D