Jump to content

New mathrandom question


Mickey and Goofy

Recommended Posts

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?

Link to comment

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 by Ranger Fox
Fixed ending code tag
Link to comment

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...