I want to use a string in my dialog

Started by Suicidal_Rabbit, Wed 23/07/2003 14:48:32

Previous topic - Next topic

Suicidal_Rabbit

I making a game where you have to fill in your name at the beginning and the game uses this name through the whole game.

I use:

string name;

InputBox("What is your name?", name);
Display ("Your name is %s.", name);

Is there a way to use this in a dialog?
'Sometimes we need insanity to keep us sane.'
http:\\www.snuffy.tk <---- Download the Beta ;)

TerranRich

First of all, you need to use the variable called "name" throughout that script. BUT, if you want to keep that variable throughout the game, simply use the character[WHOMEVER].name variable. Like so...

InputBox("What if your name?",character[EGO].name);
Display("Welcome, %s.",character[EGO].name);

And use it throughout, as it is automatically a global variable.
Status: Trying to come up with some ideas...

Vincent

but is it possible to recall the string in a dialog?

Al_Ninio

Quote from: Dryhump on Wed 23/07/2003 15:00:27
And use it throughout, as it is automatically a global variable.

I think that means "yes".
;)

Suicidal_Rabbit

The dialog doesn't support much what normal scripting does and i've tried it to use it in a dialog but it doesn't work because the character says the scripting code.
'Sometimes we need insanity to keep us sane.'
http:\\www.snuffy.tk <---- Download the Beta ;)

Al_Ninio

#5
Woops, apparently I misread your post.
And thus my answer was wrong... Sorry...
I think you'll have to use a-

Run-Script X

function for that.
Look it up in the manual.

TerranRich

And you shouldn't have to ask for help on run-script n as it is fully covered in the Beginners' FAQ, which everybody should have read. :)
Status: Trying to come up with some ideas...

Suicidal_Rabbit

I did what the manual said and now I get a parse error when I start the game... could anyone explain the run-script/ dialog_request?
maybe I didn't understand the manual good enough..
'Sometimes we need insanity to keep us sane.'
http:\\www.snuffy.tk <---- Download the Beta ;)

SSH

Post your dialog code and your dialog scirpt function
12

vincent-threepwood

in global script :

function dialog_request (int 1) {
  DisplaySpeech(EGO,"Hello i'm %s", character[EGO].name);
 }


in dialog script:

run-script 1

SSH

This is the same mistake this guy made:
http://www.agsforums.com/yabb/index.php?board=6;action=display;threadid=7458

also, TerranRich/Dryhump/StopChangingYourName, I was trying to post a link to the part of the FAQ that says about this, but I couldn't find it!

12

TerranRich

My mistake. I thought it was in there.

I thought the run-script x command was self-explanatory. Never to fear, I will host the Beginners' FAQ myself (so I can change it whenever I want to) and add this in there...




The run-script x command

Whenever you want to run regular AGS script form within a dialog script, simply run the run-script x command, where x is replaced by a number. This will call the global function called function dialog_request(int X) {..., passing X as a parameter.

What does that all mean? Well, It will run the dialog_request global function, and sets X (or whatever you want to call the variable name after the "int" part within the parentheses) to the value that you told it.

Let's say you ran "run-script 5". This would run the global function "dialog_request" and sets the integer variable (in this case, X) to 5. Now, OBVIOUSLY, you would need some way of checking what value X was given when the function is run.

Therefore, we must have a set of if...else if...else if... commands inside the dialog_request function. So, we would have something like this...

function dialog_request(int blah) {
if (blah==0) {
// This code is executed when "run-script 0" is called...
} else if (blah==1) {
// This code is executed when "run-script 1" is called...
} else...
}


Etc., etc.

So, as you see, the code would keep checking for different possible values of X or blah or whatever you want to call it, until it comes across the one that you passed with the "run-script x" command.

Get it? Got it? Good! :)


(Soon to be included in the New AGS Beginners' FAQ) :P
Status: Trying to come up with some ideas...

SMF spam blocked by CleanTalk