Register forum user name Search FAQ

Gammon Forum

Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the password reset link.
 Entire forum ➜ MUSHclient ➜ General ➜ Using wait.lua

Using wait.lua

It is now over 60 days since the last post. This thread is closed.     Refresh page


Posted by Darwin   USA  (125 posts)  Bio
Date Sat 22 Sep 2007 01:27 PM (UTC)
Message
I keep getting this error ...
Error number: 0
Event:        Run-time error
Description:  C:\Program Files\MUSHclient\lua\wait.lua:47: [string "Alias: "]:8: attempt to compare number with string

stack traceback:

	[C]: in function 'assert'

	C:\Program Files\MUSHclient\lua\wait.lua:47: in function <C:\Program Files\MUSHclient\lua\wait.lua:43>
Called by:    Function/Sub: wait.timer_resume called by timer

Reason: processing timer "wait_timer_16944"


... when trying to execute this script ...
require "wait"

load_data() -- make sure the skill table is populated
wait.make (function ()
  for i, v in ipairs(skill) do
    Send("slookup '".. v.name .."'")
    wait.time(5)
    if v.sn > 10 then -- for testing, don't want to do all of them
      break
    end
  end
end)


Here's the timer_resume function:
function timer_resume (name)
  local thread = threads [name]
  if thread then
    threads [name] = nil
    assert (coroutine.resume (thread)) -- line 47
  end -- if
end -- function timer_resume 
Top

Posted by Onoitsu2   USA  (248 posts)  Bio
Date Reply #1 on Sat 22 Sep 2007 08:42 PM (UTC)
Message
I think that the problem is on this line

if v.sn > 10 then -- for testing, don't want to do all of them

you might try surrounding the v.sn with a tonumber() call so

if tonumber(v.sn) > 10 then -- for testing, don't want to do all of them

would be the new line in its entirety. I would be able to help more if I knew the general layout of the data, but this should do the trick.
Top

Posted by Darwin   USA  (125 posts)  Bio
Date Reply #2 on Sat 22 Sep 2007 08:51 PM (UTC)
Message
It still gave that error even with that whole if block removed.
I ended up with this, which did work.
require "wait"

load_data()

function sl()
  for i, v in ipairs(skill) do
    EnableTriggerGroup ("slookup_data", true)
    SetVariable("current_sn", i)
    Send("slookup '".. v.name .."'")
    wait.time(3)
  end -- end for
end -- end sl

wait.make(sl)
Top

Posted by Nick Gammon   Australia  (23,102 posts)  Bio   Forum Administrator
Date Reply #3 on Sat 22 Sep 2007 08:52 PM (UTC)
Message
I put an assert into wait.lua because otherwise, if there is a problem in the script, it silently fails.

The "real" problem is in line 8 of your alias, see this part of the error message:


[string "Alias: "]:8: attempt to compare number with string


I see there (in line 8) you are comparing something to a number, so this is probably the problem. Try checking what v.sn is, and making sure it is a number, or converting it to one.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


17,281 views.

It is now over 60 days since the last post. This thread is closed.     Refresh page

Go to topic:           Search the forum


[Go to top] top

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.