How can I have more than one dialog request?
When I tried to put two "function dialog_request(int)" the following comes up:"Variable dialog_request already exists."
You don't need more than one, you're supposed to use the parameter to distinguish which code to run:
Example:
// dialog script A
run-script 1 // will call dialog_request(1);
// dialog script B
run-script 2 // will call dialog_request(2);
// global script
function dialog_request(int p) {
if (p==1) Display("I got called from dialog script A!");
if (p==2) Display("Dialog B caused me to happen!");
}
Thanks! Now when I only want it to run p==2, it runs p==1 and p==2. What can I do to stop this from happening?
That's strange. Are you sure, you didn't put both run-script commands in the same dialog so that they both run at the same time?
I'm completely sure. One dialog has run-script 1 and the other has run-script 2. P==2 never runs! All my dialogue requests run p==1. :'(
You must remember to put a return or stop between options if you don't want them to run in to each other...
The two run-scripts are in different dialog scripts.
There is only ONE dialog_request(). :P
Please post the content of your function for us to look at. I have some ideas but rather look at it to find what you have done wrong first.
Mind the name of the parameter.
You can use
function dialog_request(int kumquats) {
if (kumquats == 1) ...
if (kumquats == 2) ...
...
}
or whatever variable name you want, but make sure you're testing what's going to be the parameter.
Thanks! Can I put more than command after the if (p==1)? Like...
dialog_request(int p) {
if (p==1) Display("Hi"); Display(Bye!");
if (p==2) player.ChangeRoom(5); Display("You entered room 5");
Yes you can, but it will execute any command after the first every time the function is called. :P
This looks like a job for braces!
function dialog_request(int p) {
if (p == 1) {
Display("Hi");
Display("Bye");
}
else if (p == 2) {
player.ChangeRoom(5);
Display("You entered room 5");
}
}
And like a job for RTFM-Man...
Where's a superhero when you need him? ;)