Difference between revisions of "User:Dt192/Sandbox2"

From Mudlet
Jump to navigation Jump to search
m
Line 27: Line 27:
 
if portal_timer then killTimer(portal_timer) end
 
if portal_timer then killTimer(portal_timer) end
 
portal_timer = tempTimer(2, [[ send("enter portal") ]])
 
portal_timer = tempTimer(2, [[ send("enter portal") ]])
</syntaxhighlight>
 
 
 
 
<syntaxhighlight lang="lua">
 
tid = tempTimer(600, [[echo("\nYour ten minutes are up.\n")]])
 
echo("\nYou have " .. remainingTime(tid) .. " seconds left, use it wisely... \n")
 
 
-- Will produce something like:
 
 
--> You have 599.923 seconds left, use it wisely...
 
 
-- Then ten minutes time later:
 
 
--> Your ten minutes are up.
 
 
</syntaxhighlight>
 
 
 
 
<syntaxhighlight lang="lua">
 
tempTimer(1.4, [[ echo("hello, "..matches[2].."!\n") ]])
 
</syntaxhighlight>
 
 
 
 
<syntaxhighlight lang="lua">
 
tempTimer(1.4, [[ echo("hello, ]]..matches[2]..[[!\n") ]])
 
 
-- or with less brackets:
 
tempTimer(1.4, function() echo("hello, "..matches[2].."!\n") end)
 
</syntaxhighlight>
 
 
 
 
<syntaxhighlight lang="lua">
 
tempTimer(1, [=[
 
  echo("this is timer #1 reporting, 1s after being made!\n")
 
  tempTimer(1, [[
 
    echo("this is timer #2 reporting, 1s after the first one and 2s after the start\n")
 
  ]])
 
]=])
 
 
</syntaxhighlight>
 
</syntaxhighlight>

Revision as of 00:27, 16 February 2026

enableTimer("Newbie timer") -- enables the timer, so 2s after being enabled, it'll tick - and every 2s after that

disableTimer("Newbie timer") -- disables it, so it won't go off anymore


tempTimer(3, [[ echo("this is timer #1 going off 3s after being made\n") ]])
tempTimer(4, [[ echo("this is timer #2 going off 4s after being made - and 1s after the first one\n") ]])


-- get and store the timer ID in the global "greeting_timer_id" variable
greeting_timer_id = tempTimer(2, [[ echo("hello!\n") ]])

-- delete the timer - thus nothing will actually happen!
killTimer(greeting_timer_id)


if portal_timer then killTimer(portal_timer) end
portal_timer = tempTimer(2, [[ send("enter portal") ]])