Using wait.lua

Posted by Darwin on Sat 22 Sep 2007 01:27 PM — 4 posts, 22,117 views.

USA #0
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 
USA #1
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.
USA #2
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)
Australia Forum Administrator #3
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.