Scripting problem with dialog_request

Started by marcusbugger, Sat 20/09/2008 02:57:35

Previous topic - Next topic

marcusbugger

I can only use this function once..

function dialog_request (int x200)   {{}}

I can 't get a new - function dialog_request  (int x300)   {{}}

It says: variable already defined.

Maybe some little help with this?? I couldn 't get many help from the help in the program, or I don 't understand something what 's been put there.

run-script X
Runs global script function "dialog_request", with X passed as the single parameter. This allows you to do more advanced things in a dialog that are not supported as part of the dialog script. The "dialog_request" function should be placed in your game's global script file, as follows:

  function dialog_request (int xvalue) {
    if (xvalue == 1) {
     // your code here
    }
    else if (xvalue == 2) {
     // other code here
    }
  }


ThreeOhFour

"int xvalue" should be defined within the dialog, not the global script.

In the global script, place the function exactly like this:

Code: ags

function dialog_request (int xvalue){
  if (xvalue == 200){
  //code
  }
  else if (xvalue == 300){
  //code
  }
}


Then in the dialog itself, place:
Code: ags

run-script 200


At the spot you want the action to occur. Do not specify "int xvalue"'s value in the global script - this is obtained from the dialog's run-script x function.

Makes sense?

marcusbugger

#2
Quote from: Ben304 on Sat 20/09/2008 03:25:37
"int xvalue" should be defined within the dialog, not the global script.

In the global script, place the function exactly like this:

Code: ags

function dialog_request (int xvalue){
  if (xvalue == 200){
  //code
  }
  else if (xvalue == 300){
  //code
  }
}


Then in the dialog itself, place:
Code: ags

run-script 200


At the spot you want the action to occur. Do not specify "int xvalue"'s value in the global script - this is obtained from the dialog's run-script x function.

Makes sense?

Oke, it works. Thanks, I 'm dutch so it 's very hard 2 understand english sometimes..  I understood it wrong in the explanation oke, thanks Ben.

function dialog_request (int xvalue) {
   if ( xvalue == 200) {
     dialog[9].SetOptionState(3, eOptionOn);
}   
else if (xvalue == 300) {
object[1].Visible = true;
}

else if (xvalue == 1) {
dialog[7].SetOptionState(4, eOptionOn);}}

my example, above it works.... I thought that you had 2 put in value the number of the script, run-script 200, number 200 and then I had (200 == 200) + the code and it worked and then I noticed the problems came. I couldn 't get another dialog_request running. Tried - else if (300 == 300) but this didn 't work and I was "socking" around etc etc...

SMF spam blocked by CleanTalk