Scripts / Timer and "Hide" or "Show" object doesn't works...

Author
Message
Mariokiki
16
Years of Service
User Offline
Joined: 22nd Oct 2008
Location:
Posted: 31st Jan 2016 01:25
Hi,

I would like to make appearing an object after few seconds, but not with the "spawn" fonction, because the object already exists in the level but it is hidden (with hide(obj_number)

I tried to make it appear after 5 seconds using the Timer function, but it doesn't works correctly...

Take a look below.
If I'm right, the object is hidden first in "function timer_init" and shown using the variable "delay" after 5 seconds.
When I run this script, the object is shown from the start... and never hidden...

This only occurs using the Timer function with Show or Hide object.
Timer function works fine used with other functions like SetAnimation, PlayAnimation, PlaySound, CollisionOn, SetActivated...

Thanks to explain to me why it doesn't works with Show and Hide ???

THANKS !

------------------------------------------------------------
local delay = 5000 -- delai 5 secondes
function timer_init(e)
StartTimer(e)
Hide(e)
end

function timer_main(e)
if GetTimer(e) >= delay then
Show(e)
end
Prompt("Timer " .. GetTimer(e) .. " Delai " .. delay)
end
------------------------------------------------------------
PM
Pirate Myke
Forum Support
14
Years of Service
User Offline
Joined: 31st May 2010
Location: El Dorado, California
Posted: 31st Jan 2016 03:43 Edited at: 31st Jan 2016 03:46
Give this a try:



I took a look at smallg wave_timer script for spawning characters without a trigger zone.
https://forum.game-guru.com/thread/207801?page=10#msg2534312

Yes hide(e) in the init and the main is what he did.
Intel(R) Core(TM)2 Quad CPU Q6600 @ 2.40GHz, 2400 Mhz, 4 Core(s), 4 Logical Processor(s), 8gb RAM, Nvidia gtx660, Windows 7 Pro 64bit

Mariokiki
16
Years of Service
User Offline
Joined: 22nd Oct 2008
Location:
Posted: 31st Jan 2016 15:59
One more time, thanks Pirate Myke !

It works fine like this but why we need to add the "Hide(e)" command in the main function ???

Ok, stop asking you questions MarioKiki ! If this works, it's the most important...

THANKS !
PM
Pirate Myke
Forum Support
14
Years of Service
User Offline
Joined: 31st May 2010
Location: El Dorado, California
Posted: 31st Jan 2016 16:21
Your welcome, Not sure why it is needed in both to make it work, but smallg, must know a reason. Maybe he can inform us as to why.

Anyway it does work like this. That is what counts in the end.
Intel(R) Core(TM)2 Quad CPU Q6600 @ 2.40GHz, 2400 Mhz, 4 Core(s), 4 Logical Processor(s), 8gb RAM, Nvidia gtx660, Windows 7 Pro 64bit

Login to post a reply

Server time is: 2024-12-22 12:50:24
Your offset time is: 2024-12-22 12:50:24