Repeatedly Execute for Room? (SOLVED)

Started by ScottDoom, Thu 19/01/2006 19:16:12

Previous topic - Next topic

ScottDoom

I have this code but I don't know where to put it:
Code: ags
if (player.InventoryQuantity[7] > 0) && (player.InventoryQuantity[8] > 0) && (player.InventoryQuantity[10] > 0)
{ object[3].Visible = true; }
else {
Ã,  object[3].Visible = false; }


So basically if a player has the three items I want them to have, a certain object will become visible on the screen. I just threw it into the global script's repeatedly execute but I got awesome script errors and as I was trying to fix them (mostly just placements of {}'s and it also said there was a parse error with &&) I realized object 3 is room specific so it doesn't belong in the global script. I opened up the room's script editor but I'm not sure where to put it, or even if my code is correct.

Edit: I found the repeatedly execute script area for the room (went through interactions and clicked Repeatedly Execute and clicked Run Script). Anywas I pasted the above code and I get:

Error (line ##): PE04: parse error at '&&'

Ashen

#1
You need to have all the conditions inside one set of brackets, otherwise, it treats them all as seperate, rather than conditions of the same statement. So:

if ((player.InventoryQuantity[7] > 0) && (player.InventoryQuantity[8] > 0) && (player.InventoryQuantity[10] > 0))

Or:
if (player.InventoryQuantity[7] > 0 && player.InventoryQuantity[8] > 0 && player.InventoryQuantity[10] > 0)

Unless you pick up one or more of the items actually in the room, it could also go in 'Player enters screen - before fadein'. That might cause fewer problems.
I know what you're thinking ... Don't think that.

ScottDoom

#2
The character gets all the items in the room. He actually starts with one or two (can't remember now) but shhh... It's for the demo game of mine so there's only one room. I'm just practicing scripting to make it easier when I code the full game.

Anyways, that did the trick Ashen. Actually Mordalles told me over MSN before you replied, but thanks all the same.

I looked at another portion of my script though and didn't see double ()'s but I think instead I just had ( code here && code here ) instead so I got confused.

Edit: Now this just means I've got the code in there and that I'm not getting script errors. Whether or not it works I haven't tested. Can I enable debug mode to allow me to gain and lose inventory items because I haven't coded them all in yet...

SMF spam blocked by CleanTalk