I am having an issue getting a character to say different dialogues in different rooms.
Here is what the code looks like at the minute;
function cWiseSage_Talk()
{
if (player.Room != 2) dCrystals.Start();
if (player.Room != 3) dMPTutorial.Start();
}
{/code]
The game will run but bMPTutorial will run in room 2, skipping dCrystals entirely.
Quote from: alphadalekben on Sun 20/07/2014 12:16:39
bMPTutorial will run in room 2, skipping dCrystals entirely.
This is correct. The code says if the player isn't in room 2, i.e. player.Room doesn't equal (!=) room 2, then start the dCrystals dialogue.
Conversely, dCrystals will NOT start if the character IS in room 2.
How do I get it so that dCrystals DOES activate in Room 2?
I have changed the code to the following:
function cWiseSage_Talk()
{
if (player.Room = 2) dCrystals.Start();
if (player.Room = 3) dMPTutorial.Start();
}
[\code]
I also get the following error.
GlobalScript.asc(535): Error (line 535): Parse error in expr near 'player'
What am I doing wrong here?
You need == for comparison. Try changing your if statements to:
if (player.Room == 2) dCrystals.Start();
if (player.Room == 3) dMPTutorial.Start();
Cheers. I always seem to have issues with the minor stuff, strangely.
Here's the relevant manual page:
http://www.adventuregamestudio.co.uk/manual/ags46.htm#topic44
Quote from: Gurok on Sun 20/07/2014 13:07:34
You need == for comparison. Try changing your if statements to:
This was a major step for myself to conquer in understanding how the code worked actually...
I couldn't get used to why you needed a double == when testing conditions and why a simple = was used when setting them.
Then I realized that the easiest way to remember was that when testing the varible in an "if" statement you also use <= or != etc.
So you need two symbols to test the variable condition, but only one to set it ("++" and "--" are shortcuts :P)
So anyway...That's how I got used to the way it works
Sorry for double post
Ok, I've another issue now. My current code for another character is the following:
Jackson: Excuse me, sir?
MarketStall: G'day, mate.
MarketStall: What can I do ya for?
Jackson: Well, you see.
Jackson: I was wondering if you'd be so kind
Jackson: As to allow me to buy a stick of dynamite?
MarketStall: Hehehe...
Jackson: Yeah, I know.
Jackson: That sort of thing
Jackson: Would only happen in video games.
MarketStall: Hehehe...
MarketStall: I'll tell you what, my good mate.
Jackson: Yes?
MarketStall: As this is only a demo,
MarketStall: I'll let you have one on the house.
cJackson.AddInventory(iKey);
Jackson: Thank you very much.
[\code]
And this is the function:
[code=ags]
function cMarketStall_Talk()
{
dMarketDynamite.Start ();
}
[\code]
The issue is when I click the character in Talk mode, the conversation doesn't start.
I'll go on a limb ans ask if you just typed the function directly in the script, or if you actually use the event panel for the character? If you just type it, you need to click on the character you want to talk to, click on the event button and then on the "talk to character" option.
If that isn't it, you need someone that knows more about AGS than I do. ;)
Is this the entire dialog script? Because I'm not seeing the @S entry point.
There should also be a "stop" command at the end, I guess.
Thanks, Cassie, you fixed it for me. Khris, they are both there. I just didn't paste them in.
Yes, like I told you before (http://www.adventuregamestudio.co.uk/forums/index.php?topic=50722.msg636492780#msg636492780), you can't just type functions into the script and expect them to be called by AGS, you have to link them to the event.
(This is why I assumed something else was the cause here.)
Another minor issue again. I'm trying to get the character to say a different dialogue depending on the player's View and I'm getting this error;
GlobalScript.asc(541): Error (line 541): PE04: parse error at ';'
Here's what my code looks like at the moment;
function cWiseSage_Talk()
{
if (player.Room == 2) dCrystals.Start();
if (player.Room == 3) dMPTutorial.Start();
if (player.Room == 4);
{
if (player.View == 13) dCaveDynamite.Start();
if (player.View == 14) dRockDynamite.Start();
}
}
The issue results from the bottom few statements.
QuoteGlobalScript.asc(541): Error (line 541): PE04: parse error at ';'
For starters if statements do not end with a ; .....this is the error
I get this error when I remove the semicolon;
Dialog 3(20): Error (line 20): expected semicolon after ')'
you have not given anything to happen after that function, it's blank.
You need to read manual or do a search here for more about adding functions, if, else if and else statements....
This problem is a fairly basic one that crops up all the time.
You should not expect to always get a complete script written for you but rather help and advice and a kick in the right direction and there are some magic scripters here ;)
Thanks. It was a mind-fart on my part anyway. I thought the error referred to the Global Script, not Dialogue 3. My bad.