Page 1 of 1

tempTimer is going off immediately

Posted: Fri Dec 14, 2018 6:01 pm
by Katerine459
I have what I hope is a simple question. I have an alias, where I want to send the "sc" command (to get the "score" screen), then wait for the score screen to appear (because there's a separate trigger to get the number of coins I have in hand), then run another command. Here's the alias code (called depc):

Code: Select all

local function DepositCoins()
  local CoinsToDeposit = CoinsInHand - math.fmod(CoinsInHand,5000)
  send("deposit " .. CoinsToDeposit)


But even when the tempTimer is set to a ridiculous number of seconds (like the 20, above), there is no wait. The "sc" command gets sent, then "deposit x" (where x is the number of coins) is sent immediately after that, and then the "sc" command comes through.

So... here's what I know. It's not that the code doesn't work at all... it does. It's not that the code is running out of order... it isn't ("sc" is sent first, then deposit x"). It's that the tempTimer does not appear to be, well, doing a temp timer.

Using Mudlet 3.15.0.


Re: tempTimer is going off immediately

Posted: Fri Dec 14, 2018 8:29 pm
by Zaphob
Hi Katerine459!

The tempTimer will indeed wait for you, however the syntax needs to be a bit different. The way you wrote it, your function will be executed immediately when defining the Trigger. The result of your function will then be used as argument for said trigger when the time is done. That will probably not help or be what you want. Instead you have two options:

1) Wrap your function name as a string with "" or [[]] like so:

Code: Select all

This is the old way and works fine. However it will break syntax highlighting and can become a bit ugly when longer functions are involved.

2) Since some recent Mudlet version, you can also use anonymous functions in this place:

Code: Select all

tempTimer(20,function() DepositCoins() end)

See more information in wiki:

Let us know if this helps or you need any other support :)

Re: tempTimer is going off immediately

Posted: Mon Dec 17, 2018 5:32 pm
by Katerine459
Thanks! That did the trick. :)