Using Timers or adding step delays in a pie menu option?
Author
Message
Technomancer
Joined: Sat Jul 31, 2010 10:01 pm Posts: 42
Using Timers or adding step delays in a pie menu option?
I'm not sure of the best way to describe what I'm after, but essentially, I have a toggling pie menu button. When the button is toggled, it's meant to animate up through 3 frames on an attachable then change the actors sharpness to 1, or animate down through 3 frames and change sharpness to 0. The rest of the script in update(self) makes the frame-by-frame changes I want to the actors motion if sharpness is 1, and that's working fine. So is the toggling.
The problem seems to be, I don't seem to be able to make the pie-triggered part of the script keep running past a single frame. Is there any way around this besides moving the (brief, and only on toggle) animation into update(self) as well?
Here's the relevant part of the script. The text message for a missing wing isn't working either, but that's probably because it returns an error and stops the code if the attachable isn't picked up by the ID sweep, rather than passing through as a false.
Code:
function ToggleStable(actor) local MoObj for i = 1, MovableMan:GetMOIDCount()-1 do if MovableMan:GetRootMOID(i) == actor.ID then MoObj = MovableMan:GetMOFromID(i) if MoObj.PresetName == "Ven Cherub Wing" then actor.Wing = ToAttachable(MoObj) break end end end actor.FrameTimer = Timer(); if actor.Sharpness == 0 then if actor.Wing:IsAttached() then if actor.FrameTimer:IsPastSimMS(50) then actor.Wing.Frame = 1; end if actor.FrameTimer:IsPastSimMS(100) then actor.Wing.Frame = 2; end if actor.FrameTimer:IsPastSimMS(150) then actor.Wing.Frame = 3; actor.Sharpness = 1; actor.FrameTimer:Reset(); end else actor.Wing = nil; FrameMan:SetScreenText("Stabilizer Wing Missing", actor.GetController, 0, -1, false); end else if actor.Wing:IsAttached() then actor.Wing.Frame = 0; actor.Sharpness = 0; else actor.Wing = nil; FrameMan:SetScreenText("Stabilizer Wing Missing", actor.GetController, 0, -1, false); end end end
It doesn't work if I try doing:
for i = 1, 3 do if actor.FrameTimer:IsPastSimMS(50 * i) then actor.Wing.Frame = i; end
either. Am I just making a really stupid mistake somewhere? I'm pretty sure triggering via the pie menu skips the Create(self) and Update(self) sections.
EDIT: The else section for turning off the stabilizer doesn't include the steps down here, but ideally it will, it's just that it wasn't working on the way up so it seemed silly to break it going down as well.
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot post attachments in this forum