I wonder how many of you have found the yesnoPopup
stupid. Why tf the codes under this popup will be excuted right after the popup instead of after the selection is made? I know that it's assumed that the codes related to the selection should be put into the fct
parameter, but in some cases we really want to return
something according to the selection.
To make things worse, Lua doesn't support multithreading.
After some complaining and days of researching, I come out with a solution:
Code: Select all
local ret = nil
local main = coroutine.running()
Dialog:yesnoPopup("title", "context", function(ok)
ret = ok
I put this into a use_power.use
and it works well. However if you just execute coroutine.yield()
out of the game and without anything else you'll get an error "attempt to yield from outside a coroutine"
. So there could be situations where this solution doens't work.