Page 2 of 2
Re: Wait and Wait Line
Posted: Fri Feb 19, 2021 7:04 am
by nowhereman
I've changed:
Code: Select all
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.
-Nowhere.
Re: Wait and Wait Line
Posted: Tue Mar 16, 2021 2:56 pm
by zhenzh
You are correct. Timeout function doesn't point to the correct trigger id.
But your fix can only process single line case, I have fixed it to afford both single line and multiple line cases:
Code: Select all
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
Re: Wait and Wait Line
Posted: Sun Jul 17, 2022 5:14 am
by tyst8
hi, does this still work on mudlet v 4.16.0? I downloaded from post #1 and made this code
Code: Select all
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)()
and calling this function from a trigger:
Code: Select all
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>
Re: Wait and Wait Line
Posted: Tue Nov 22, 2022 8:42 pm
by Vagonuth
First off, thank you for this module! It's incredibly helpful.
I was wondering if anyone had a way of making it so a function with a wait() in it could be called and delay what it returns. For example:
Code: Select all
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.