This is almost certainly something mind-blowingly simple, but...
I have some simple code in a room to determine if 4 separate hotspots have been clicked on. When they are, it sets an integer to 1. I have some repeatedly executed code to check if the total of these four integers is 4. So far so good.
All works fine and dandy until I add in chancing the room (which is the whole purpose of this code, to determine if the exit criteria are met before moving on). At this point the room hangs at startup.
function room_RepExec()
{
if (P1+P2+P3+P4==4)
{Display("All four wood panels found");
cTan.ChangeRoom(7, 10, 68);}
}
I've been looking through the tutorials etc but atm can't see what I'm doing wrong. Any help much appreciated!
Hey there CaptainD
Im no expert myself, and maybe the Problem is something with the room you wanna load, but most likely ist like this:
function room_RepExec() -> calls in all the time, because you wanna check, thats ok.
BUT 3.if (P1+P2+P3+P4==4) stays true, right?
so 4.{Display("All four wood panels found");
5.cTan.ChangeRoom(7, 10, 68);}
might be called infinite.
Maybe just set the P1-4 back to 0, or add another variable to deactivate the code after ist called.
Apart from this, i would rather use bool for this, but thats up to you.
Hope this helps, and if not an expert will most likely find this Topic ;)
greez Stromvin
Not sure what the problem is, but you don't need to run that check each loop.
function checkPanels() {
if (P1 + P2 + P3 + P4 < 4) return;
Display("All four wood panels found");
cTan.ChangeRoom(7, 10, 68);
}
// further down, in the hotspots' code
P1 = 1;
checkPanels();
Thank you both very much for your replies. I'll try out Khris' code, my own programming experience is very much rooted in late 80s / early 90s BASIC so it's taking me a while to get my mindset around AGS scripting, but reading that I can actually make sense of it very easily.