Using the run-script x function in dialog

Started by , Sat 15/05/2004 07:35:15

Previous topic - Next topic

I need help!!!!!!

In the tutorial it says that if you want to use a script command that can't be used in dialog script, you use run-script x, and in the global script, you put:
  function dialog_request (int xvalue) {
    // your code here
  }
I needed two different scripts to be run in two different places in my dialog so I did:
(In dialog script):
run-script 1
(in another place)
run-script 2
(In the global script, at the top)
  function dialog_request (int 1) {
    // code here
  }
  function dialog_request (int 2) {
    // code here
  }
Since I wasn't exactly sure what (int xvalue) ment, in tems of wether you do (int 1) or (1) or (int 1value), I tried different ways. I either got an error message saying there was a parse error at the 1 in the first line of the global script, or that the variable dialog_request has already been defined. (The second error message pointed to the line:
function dialog_request (int 2) {
Please help if you can!

strazer


Scorpiorus

TerranRICH: after upgrading of the forums the font of link to the AGS Beginners FAQ became too tiny. Newcomers may not even notice it. This is great FAQ by the way!

http://www.agsforums.com/yabb/index.php?topic=4752.0

Scummbuddy

yeah, i noticed that earlier today, but i thought that terranrich did that on purpose because his site was down, but yeah its now on rainday, thanks for the link and the heads up.  it said the font size was +1, so now its 17.
- Oh great, I'm stuck in colonial times, tentacles are taking over the world, and now the toilets backing up.
- No, I mean it's really STUCK. Like adventure-game stuck.
-Hoagie from DOTT

TerranRich

Wow. Well, thanks for increasing the size of that link. It must be as obvious as humanly possible, because newcomers seem to be ignoring the BFAQ.

I've always wondered why the dialog_request system was so hard to comprehend. You call a function and send it a value. This function has to check said value. If it's 1, do this, if it's 2, do that, etc., etc. That's all there is to it. :)
Status: Trying to come up with some ideas...

Scorpiorus

Quote from: terranRICH on Tue 18/05/2004 04:48:22I've always wondered why the dialog_request system was so hard to comprehend. You call a function and send it a value. This function has to check said value. If it's 1, do this, if it's 2, do that, etc., etc. That's all there is to it. :)
Think I know, why that is. I just browsed the manual for the dialog_request function and found out that the example of it's use is:

* 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
Ã,  }


You see, there is no if (xvalue==...) etc!
And, furthermore, unlike the interface_click(), on_mouse_click() functions it's not in the global script, so newbies have to put it themselves.

If a person isn't familiar with "if" he(she) most likely put:

function dialog_request (int 2) {
Ã,  Ã,  // your code here
Ã,  }

function dialog_request (int 3) {
Ã,  Ã,  // your code here
Ã,  }

It's great we have the FAQ to get info from but maybe it could be a good idea to point out that fact in the AGS manual too?

Gilbert

Actually I think the dialog request thingie is not really that easy to understand, especially for people with little scripting experience in AGS.

There is indeed a steep slope preventing in-experienced users to jump from "basic" level (no or VERY little text scripting involved) to "intermediate" level (some scripting involved, which includes passing a parameter to a user-defined function).

Comparing the dialog scripting system and text scripting system in AGS, which are different, understanding the dialog scripting system seems to be much easier for most users (and is essential for most games), so it's in "basic" level.
But when you want to do some small "neat" stuffs within dialogs, users has to jump into "intermediate" level, as they now need to script on dialog_request() which involves the handling of a parameter, which is not that easy for most people (though some of the more experienced users may not understand).

So I appreciate anyone who are helpful and put info clear for this kind of stuffs (in FAQs, answering posts, etc.), as this is very helpful to newbies.

Scorpiorus

Yep, it could be difficult to get into the scripting stuff. The great thing about the dialog_request() is that it is one of those "windows" through which an unexperienced scripter may find his way to the "intermediate" level.

I get it so, most of the newbies first exploring the interaction editor (no scripting required), next learning the dialog scripting (simple but yet very helpful) where they notice a run-script command and, finally, trying to add text script commands via the dialog_request. I'm sure that if the dialog request already were in the global script (default template):

function dialog_request (int value) {

   if (value == 0) {

      //your code for value == 0
   }
   else if (value == 1) {

      //your code for value == 1
   }

}

...most of the newbies would figure out how it is supposed to organize it in a right way. Similar to how we already have the interface_click function.

Just my two cents...

Gilbert

Yeah, but one problem is that usually the users have to create dialog_request() themselves, in contrast to interface_click(), which under normal circumstances, is already there and even includes some sample codes in it when you start a new game (unless you start from some "blank" template), and they may not be aware that they can handle the dialog_request function in a similar way.

Scorpiorus

So what everybody think if there was the dialog_request function in the global script, with the if (value==...) statements inside?

A person who started the topic does know what he(she) is after, it just a matter of syntax. It's like with the interface_click() function - one doesn't even need to know where from and how the interface_click function is called, just put
if (interface == MYGUI)

   if (button == MYBUTTONNUM)
   {

      // what I want to happen
   }
:)

strazer

QuoteIt's great we have the FAQ to get info from but maybe it could be a good idea to point out that fact in the AGS manual too?

QuoteSo what everybody think if there was the dialog_request function in the global script, with the if (value==...) statements inside?

I think both of these are excellent ideas.

Gilbert

#11
Can be nice, but should be put as comments, like (as unlike there's a default GUI, there shouldn't be default stuffs in dialogs):

function dialog_request (int num) {
  //Executes when called from within a dialog
  //You can check the value of num and script accordingly.
  //Eg:
  // if (num==1) {//when run-script 1 is called
  //Ã,  Ã,  } else if (num==2) {Ã,  //when run-script 2 is called
  //Ã,  Ã,  Ã,  Ã,  } //etc.
  }

Scorpiorus

Yeah, as long as there are instructions provided what needs to be uncommented (like for the custom inventory window).
On the other hand, if all 'if' {} - blocks are left blank there shouldn't be problems with leaving it even uncommented.

SMF spam blocked by CleanTalk