Why is this script not working? - Want Room to switch from room 5 to room 6

Started by MCF, Fri 19/12/2003 03:20:06

Previous topic - Next topic

MCF

After 5 seconds, the room should switch from 5 to 6.  What is wrong with my timer?

// room script file

function room_a() {
 // script for room: Player enters screen (before fadein)

GUIOn (0);
GUIOn (1);  

SetObjectView (0, 7);
AnimateObject (0, 0, 15, 1);
SetTimer (1, 5*GetGameSpeed());

}

function room_b() {
 // script for room: Repeatedly execute

if (IsTimerExpired (1) ==1) {
   NewRoom(6);
}

}

Timosity

Try putting this bit after fadein

// script for room: Player enters screen (after fadein)

SetObjectView (0, 7);
AnimateObject (0, 0, 15, 1);
SetTimer (1, 5*GetGameSpeed());



or even just this line

SetTimer (1, 5*GetGameSpeed());


hope that works

~Tim

MCF

That didn't work.  It just keeps running the animation and never changes room.

James Kay

Not being a programmer and having a penchant for talking out of my arse, have you tried

AnimateObjectEx( blah blah blah, 0);
?

It's what I use for incidental anims. Any non-Ex AnimateThing script I used always appeared blocking.

Timosity

You have the animation set to repeat so it should continuously repeat, I assume that's what you want to happen until the timer expires.

What is the game speed set to? maybe you have to physically set the game speed first, cause maybe it's setting the timer to 0 which cancels the timer.

I'd say it has something to do with the timer because that's the only bit of your script not working, just have a play around with it.

Try what James Kay suggested, but I don't see how it would make much difference with the way you've done it already, cause it's already a non blocking function. but sometimes these things work.

MCF

I'm not sure I fully understand the setgamespeed() command.  Isn't the default 40 -- that is, if I wrote wait(40); the game would pause for 1 second?

I tried just setting the timer as 120, hoping for a 3 second delay before the time expires and the game goes to the next room.   It didn't work.

I then tried setting the time as 3, thinking that is a mere fraction of a second.  It also didn't work.

Something tells me the timer isn't being set correctly, or is being reset.  


Timosity

I was curious why it wasn't working so I made a test game with 2 rooms and used your code (copy & paste from here, except the guion's and different object animation numbers)

It works fine in before or after fadein and even with the getgamespeed() part.

I don't know why it's not working for you, maybe there's some other code that is stopping it from working.

Sorry I can't help, cause it seems you've done nothing wrong, maybe someone could move this to the tech forum and get Pumaman to see if he knows a possible problem.

If your not too far in maybe you could start it again, but you may have to upload it somewhere for someone to have a look at ie. Pumaman

otherwise there is just something really simple your missing.

SSH

Are you using timer 1 anywhere else? Are you checking it anywhere else? The expired function only returns 1 ONCE, so if you call it twice, even in the same game cycle, it will only work the first time. CHeck all your other scripts and espeically your global and room rep_exs
12

MCF

I just bagged the code and re-wrote it.  Now everything is fine.

SMF spam blocked by CleanTalk