+Mickey and Goofy Posted July 4, 2011 Posted July 4, 2011 I would like to make a ztimer with a random "Duration" I have this: ztimerpoty = Wherigo.ZTimer(cartNotToday)ztimerstop.Id="58fd2c91-7b05-48a2-a3b9-88aac2df6e19" ztimerstop.Name="stop" ztimerstop.Description=[[]] ztimerstop.Visible=true ztimerstop.Duration=180 ztimerstop.Type="Countdown" Can I move it to the "-- #Author Functions Go Here# --" section like this: -- #Author Functions Go Here# -- function RandomTime() ztimerstop = Wherigo.ZTimer(cartNotToday) ztimerstop.Id="58fd2c91-7b05-48a2-a3b9-88aac2df6e19" ztimerstop.Name="stop" ztimerstop.Description=[[]] ztimerstop.Visible=true ztimerstop.Duration=math.random(180,300) ztimerstop.Type="Countdown" end -- #End Author Functions# -- Or is there a better way? Quote
Ranger Fox Posted July 5, 2011 Posted July 5, 2011 (edited) You should be able to set just the timer's duration in the author script section; you shouldn't have to create a new timer each time you want to use one. I use timers a lot in Whack-A-Lackey and have to give them a random time as well. Here's an excerpt from the code. In it, I'm looping through all the timers (the moleTimers is a lua table/array), stopping them, setting their duration to a random time, and restarting them. for x=1,numMoles do moleTimers[x]:Stop() moleTimers[x].Duration = math.random(minTimerSeconds,maxTimerSeconds) moleTimers[x]:Start() end Edited July 5, 2011 by Ranger Fox Fixed ending code tag Quote
+Mickey and Goofy Posted July 8, 2011 Author Posted July 8, 2011 Thanks I'll use it and take another look at your Whack-A-Lackey. Lon Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.