I need a bit of scripting help with player hiding.

Started by Josh R, Wed 23/11/2005 01:20:32

Previous topic - Next topic

Josh R

I have a puzzle that involves walking behind an area in order to hide, similar to hiding from the droid at the beginning of sq4. But in this puzzle, you have to knock on a door before hiding. I have set up a timer, so you knock on the door, and you have a short ammount of time to get behind the object. If you do not hide in time, you will get a game message.

However, I have a lot of variables going, and there are a few things I haven't quite figured out for this puzzle.

I can get my hidden variable to work correctly. But now I want to display a message when the player is not hidden, and the timer has run out.

For some reason I can't seem to make that happen. The hidden variable is working correctly, but I can't make it work right when the timer expires.

// script for Room: Repeatedly execute
if (IsTimerExpired(1) == 1) {
while (GetGraphicalVariable("Hidden") == 0) 
Display("You have not successfully hidden");
}

I also tried it on a hotspot, and I tried it with "if" instead of while, but it doesn't seem to work either way. Any help is appreciated.

Gilbert

Did you use two IsTimerExpired() in the code, one for "Hidden==1", another for "Hidden==0" ?
Notice that when the time expires and you check it via IsTimerExpired(), the timer is reset, so, the next time you check it, it'll be 0.

Recommended codes are:
// script for Room: Repeatedly execute
if (IsTimerExpired(1) == 1) {
if (GetGraphicalVariable("Hidden") == 1) {
  //do something blah bla bla
} else Display("You have not successfully hidden");
}

Note that "while" is not appropiate in your code, as you're not going to make a loop.

Josh R

Yeah, the timer will be at 0, but you can restart it by knocking on the door again, which gives you another chance at hiding.

I'm not sure I understand what you are saying about using two IsTimerExpired codes. Should I use two, or should I not use two? At the moment I am just using that one within the code.

Gilbert

I meant, you should not, so it's okay if you're using only one.
Are you sure that "Hidden" got set correctly, and it's initially zero ?

Josh R

Thank you. I managed to get it after several hours of tinkering. I have like 10 variables in the scene, so it got tricky.

SMF spam blocked by CleanTalk