Back with another question...
I'm wondering how to execute a different dialog the second time around, I thought that using a variable would be the best idea, so I have
"
9 function hGuard_Talk()
10 if (myCounter1 == 0)
11 {
12 dGuard.Start();
13 }
14 if (myCounter1 >= 1)
15 {
16 dGuardc.Start();
"
When i try to run the game, it tells me
Failed to save room room18.crm; details below
room18.asc(9): Error (line 9): Expected '{'
If i put brackets on line 9 it says "Unexpected "{""
if I put the "if (mycounter1 == 0) in brackets, it says that mycounter1 is an undefined symbol
EDIT: Never Mind, resolved that problem, by doing
"function hGuard_Talk()
{if (myCounter1 == 0)
dGuard.Start();
if (myCounter1 >= 1)
dGuardc.Start();
}"
Have a look at the Game.do_once_only function :)
It makes these situations a lot simpler if you only want to execute the first dialog once!
Not to mention that your problem occurred due to strange tabbing and dirty code.
I don't want to sound vain, but I (and many other AGSers and scripters) would write your code like so:
function hGuard_Talk() {
if (myCounter1 == 0) {
dGuard.Start();
}
else if (myCounter1 >= 1) {
dGuardc.Start();
}
}
OR
function hGuard_Talk()
{
if (myCounter1 == 0)
{
dGuard.Start();
}
else if (myCounter1 >= 1)
{
dGuardc.Start();
}
}
OR
function hGuard_Talk()
{
if (myCounter1 == 0) dGuard.Start();
else if (myCounter1 >= 1) dGuardc.Start();
}
So that you can clearly see the beginning and end of each function, if, while, etc. Related: You can press Ctrl-B when next to a bracket or parenthesis, and it will highlight its pair.
~Trent
Hehe yeah, that's good advice. Having your brackets and parenthesis is not being vain, it is making life easier for yourself when you're digging through a script to try and find bugs!
Trent, I didn't know about the Ctrl + B function, that's cool, thanks for sharing :D