Hi
I'm having problems with setting an object properties and checking if the object image is a certain number to run the global int.
Basically the objects image number to start with is 1218 and after an interaction the image changes to 1226 which works ok,
Then I want to check if the image has changed to run another interaction when the object is visible.
I keep getting a parse error near 'object'
any help would be grateful thanks
Here's my example:
if (ObjectOn(2) && (object[2].Graphic = 1226);){
Ã, SetGlobalInt (30, 1);
}
Quote from: Lazarus on Mon 30/01/2006 12:33:10
(object[2].Graphic = 1226); )
Well, you want to get rid of that semicolon ";" for starters
There's a few problems there. I'd say it should be:
if (object[2].Visible && object[2].Graphic == 1226) {
SetGlobalInt(30, 1);
}
1. Since you're using version 2.7, the Object.Visible property is preferable to the obsolete ObjectOn/Off(..) commands. (And anyway, for checking you'd have used IsObjectOn(x).)
2. You use == to check, and = to set (so if (object[2].Graphic == 1226), not if (object[2].Graphic = 1226)). This is probably what caused the parse error.
3. You don't really need the paranthesis around the graphic part of the condition (although provided they match up it shouldn't be a problem). Extra conditions can just be included in the main set ( if (x == 1 && y == 2 && z == 3)).
However, you definately don't want the ; as SSH said.
EDIT: Well, yes, good point.
hmmm, yes, i should have spotted the = /== thing
but, "== true" is an entirely redundant expression. The following is sufficient:
if (object[2].Visible && object[2].Graphic == 1226) {
SetGlobalInt(30, 1);
}
Thanks for the help works perfect now
I have another question
At the moment I'm using this code in the room 89 repeatedly execute.
if (object[2].Visible == true && object[2].Graphic == 1226) {
Ã, SetGlobalInt(30, 1);
}
else SetGlobalInt(30, 0);
if (object[3].Visible == true && object[3].Graphic == 1222) {
Ã, SetGlobalInt(31, 1);
}
else SetGlobalInt(31, 0);
if (object[6].Visible == true && object[6].Graphic == 1228) {
Ã, SetGlobalInt(32, 1);
}
else SetGlobalInt(32, 0);
if (object[9].Visible == true && object[9].Graphic == 1232) {
Ã, SetGlobalInt(33, 1);
}
else SetGlobalInt(33, 0);
if ((GetGlobalInt(30) == 1) && (GetGlobalInt(31) == 1) && (GetGlobalInt(32) == 1) && (GetGlobalInt(33) == 1)){
Ã, Display("Congratulations you've solved this puzzle");
Ã, Wait(100);
Ã, player.ChangeRoom (90);
}
which works okay, but I was then thinking of changing this so I got a reply when each puzzle was completed like this for example:
if (GetGlobalInt(30) == 1){
Display("This one is correct");
SetGlobalInt(34, 1);
}
else SetGlobalInt(30, 0);
if (GetGlobalInt(31) == 1){
Display("This one looks right");
SetGlobalInt(35, 1);
}
else SetGlobalInt(31, 0);
if (GetGlobalInt(32) == 1){
Display("Well done this one is solved");
SetGlobalInt(36, 1);
}
else SetGlobalInt(32, 0);
if (GetGlobalInt(33) == 1){
Display("You've solved this one");
SetGlobalInt(37, 1);
}
else SetGlobalInt(33, 0);
if ((GetGlobalInt(34) == 1) && (GetGlobalInt(35) == 1) && (GetGlobalInt(36) == 1) && (GetGlobalInt(37) == 1)){
Display("Congratulations you've solved all the puzzles");
Wait(100);
player.ChangeRoom (90);
}
But when I try this all that happens is for example depending on which puzzle is done "Display("This one looks right");" keeps repeating and not letting me do enything else, is there away so it only happens once? so the player then go and solve the other three puzzles.
thanks in advance
Try This (I couldn't understand the logic of your new codes, so I just modified the old codes):
if (object[2].Visible == true && object[2].Graphic == 1226&&GetGlobalInt(30)==0) {
SetGlobalInt(30, 1);
Display("This one is correct");
}
else SetGlobalInt(30, 0);
if (object[3].Visible == true && object[3].Graphic == 1222&&GetGlobalInt(31)==0) {
SetGlobalInt(31, 1);
Display("This one looks right");
}
else SetGlobalInt(31, 0);
if (object[6].Visible == true && object[6].Graphic == 1228&&GetGlobalInt(32)==0) {
SetGlobalInt(32, 1);
Display("Well done this one is solved");
}
else SetGlobalInt(32, 0);
if (object[9].Visible == true && object[9].Graphic == 1232&&GetGlobalInt(33)==0) {
SetGlobalInt(33, 1);
Display("You've solved this one");
}
else SetGlobalInt(33, 0);
if ((GetGlobalInt(30) == 1) && (GetGlobalInt(31) == 1) && (GetGlobalInt(32) == 1) && (GetGlobalInt(33) == 1)){
Display("Congratulations you've solved this puzzle");
Wait(100);
player.ChangeRoom (90);
}