Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: on Sat 24/07/2004 14:45:49

Title: run-script, function dialog_request
Post by: on Sat 24/07/2004 14:45:49
ok so i am creating a dialog and i type the following:

run-script 1

in the tutorial it says the following:

run-script X
Runs global text 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) {
    // your code here
  }

so i go to script > edit global script and type the following:

function dialog_request (int 1) {
(and i insert my code here)
}

ok, i save it and now i am going to save the game...
now, here is where i get my proplem:

  there was an error compiling your script. The proplem was in the Main script
 
  error (line **): PE02: Parse error at '1


and now he takes me here:

function dialog_request (int 1) {


Can anyone help??? i have tried everything
Title: Re: run-script, function dialog_request
Post by: monkey0506 on Sat 24/07/2004 15:49:28
Might I suggest removing the "int" from your script? IE:

function dialog_request(1){
//blah blah blah
}

or perhaps leave the int as xvalue?

function dialog_request(int xvalue){
//blah blah blah
}

I'm not sure, as I haven't done much work with dialogs yet, but, one of the two might be correct...
Title: Re: run-script, function dialog_request
Post by: Mr Flibble on Sat 24/07/2004 16:17:42
Okay. Very simple.
function dialog_request (int param)
Leave this as is.
Then for "run-script 1" Put

if (param ==1) {
//code here
}

Thats about the long and short of it. i personally think it isn't verywell covered by the manual, so don't be embarrassed.
Title: Re: run-script, function dialog_request
Post by: BlackMan890 on Sat 24/07/2004 16:17:42
Thanks a lot ;)

it works

but still, i cant put 'if' in it
oh well, thanks for the help ;)
Title: Re: run-script, function dialog_request
Post by: Mr Flibble on Sat 24/07/2004 16:20:41
Well, you can't mix dialog script with regular global script and neither can you do vice versa.
I forget the exact code for this, so I can't really help.

You could do a run script to check global ints to see if the merchant has something in stock, then RunDialog.
Title: Re: run-script, function dialog_request
Post by: BlackMan890 on Sat 24/07/2004 16:24:49
thanks, i will remember that,
thanks for the help
Title: Re: run-script, function dialog_request
Post by: 1,000 hours on Mon 26/07/2004 13:29:47
this is driving me crazy. i want an object to turn on at the end of the conversation. in my dialog script i have put:

run-script 1

and in the global script i wrote this from scatch:

#sectionstart dialog_request// DO NOT EDIT OR REMOVE THIS LINE
function dialog_request(int value) {
if (value == 1) {
//ObjectOn (4)
}
}
#sectionend dialog_request// DO NOT EDIT OR REMOVE THIS LINE

But nothing happens? any help is apreciated
Title: Re: run-script, function dialog_request
Post by: Gilbert on Tue 27/07/2004 02:34:16
The reason is obvious, as you did nothing in the function, since you commented the line in it, remove the // and it should work:

#sectionstart dialog_request// DO NOT EDIT OR REMOVE THIS LINE
function dialog_request(int value) {
if (value == 1) {
  ObjectOn (4)
  }
}
#sectionend dialog_request// DO NOT EDIT OR REMOVE THIS LINE
Title: Re: run-script, function dialog_request
Post by: Moox on Tue 27/07/2004 02:41:42
It also needs a ; at the end of it
Title: Re: run-script, function dialog_request
Post by: Gilbert on Tue 27/07/2004 02:45:54
yeah right
Title: Re: run-script, function dialog_request
Post by: 1,000 hours on Tue 27/07/2004 20:34:17
oh thanks loads i'll try it in a bit, where do i put the ; though?
Title: Re: run-script, function dialog_request
Post by: Mr Flibble on Tue 27/07/2004 21:02:24
function dialog_request(int value) {
if (value == 1) {
Ã,  ObjectOn (4);
Ã,  }
}
#sectionend dialog_request// DO NOT EDIT OR REMOVE THIS LINE
It goes in after the ")" to tell AGS that it has come to the end of a line, so anything after is a new statement.
// are comment lines. AGS will not read them; they are little notes for your benefit.
eg. ObjectOn(4); // the vase
Title: Re: run-script, function dialog_request
Post by: 1,000 hours on Wed 28/07/2004 18:56:58
thanks for your help. I got the item to swtich on just fine now. but when i tried to have another 'run-script' option in my dialog i messed up again. i wanted the characters view to change at the end of the conversation and I've got this in my script:

function dialog_request(int value) {
if (value==1) {
ObjectOn (4);
if (value==2) {
SetCharacterView (JAY, 4);
}
}
}

nothing happens, the veiw does not change.
Title: Re: run-script, function dialog_request
Post by: BlackMan890 on Wed 28/07/2004 19:01:22
i think it is suposed to be like this:

function dialog_request(int value) {
if (value==1) {
ObjectOn (4);
}

if (value==2) {
SetCharacterView (JAY, 4);
}
}

or this:

function dialog_request(int value) {
if (value==1) {
ObjectOn (4);
elseif (value==2) {
SetCharacterView (JAY, 4);
}
}
Title: Re: run-script, function dialog_request
Post by: 1,000 hours on Wed 28/07/2004 19:35:49
solved it. sorry my stupid fault. i was changing it to the wrong view number  ::)