function wait_line_timer(name)
for _,v in ipairs(threads[name][2]) do
if v ~= nil and v[1] ~= nil then
disableTrigger(v[1])
killTrigger(v[1])
end
end
wait_line_resume(name)
end
as when the triggers would fail to resolve their regex the timers would expired and next time I got a successful trigger, i'd get multiple triggers stacking up. It's a quick fix. I think it might be correct. Submitting here as both a bug report and a proposed solution.
function wait_line_timer(name)
for _,v in ipairs(threads[name][2]) do
for _,i in ipairs(v) do
disableTrigger(i)
killTrigger(i)
end
end
wait_line_resume(name)
end
The new version with the fix is uploaded, you can download it from the link in #1 post
coroutine.wrap(
function()
while true do
local result = wait_line([[^You killed (.{0,4}]],2)
if result[2] then
cecho("\n<orange>we killed: " ..result[2])
end
end
end)()
function enemyStatus(target,t)
result = wait_line([[^You killed (.{0,4}]],t)
if result[2] == target then
return true
else
return false
end
end
both are giving me this error about attempt to index local 'result':
wait_line(): [string "Alias: alias - test"]:5: attempt to index local 'result' (a boolean value)
details: stack traceback:
[string "Alias: alias - test"]:5: in function <[string "Alias: alias - test"]:2>
Last edited by tyst8 on Sun Jul 17, 2022 5:17 am, edited 2 times in total.
function foo()
coroutine.wrap(
function()
wait(3)
return "bar"
end)()
return "sadface"
end
print(foo())
> sadface
In this example, it will print "sadface". However, it would be nice to have the functionality in that the called to foo would be delayed for 3 seconds and then it prints "bar". I suspect this is possible with the way its implemented but wanted to check.
@Vagonuth
I think you may get something misunderstood. The wait module uses coroutine suspend/yield function to implement the action WAIT. So, it requires all your codes are included by an overall coroutine.
In your example, the foo() and print() function will not be correctly controlled by the wait module as they are not in the same coroutine. The coroutine.wrap() you called impacts on the code return "bar" only.
Should work, the module is composed with pure lua code which should not be impacted on the release update of mudlet, unless tempTrigger() and tempTimer() get incompatible.
wait_line(): [string "Alias: alias - test"]:5: attempt to index local 'result' (a boolean value)
Since the wait_line() returns false when match failed, I guess your regext pattern may doesn't work for your trigger line.