ParkourPenguin I post too much
Reputation: 150 Joined: 06 Jul 2014 Posts: 4654
|
Posted: Fri Feb 11, 2022 9:02 pm Post subject: |
|
|
In the janky experimentation I'm doing, I guess createTimer might need to be called from the main thread.
Using events like DB suggested in that linked topic would likely be better. Maybe something like this:
Code: | [ENABLE]
{$lua}
if syntaxcheck then return end
if myScriptStuff then
myScriptStuff.thread.terminate()
if myScriptStuff.event then
myScriptStuff.event.setEvent()
end
myScriptStuff = nil
end
myScriptStuff = {}
local event = createEvent(false, false)
myScriptStuff.event = event
myScriptStuff.thread = createThread(function(t)
while not t.Terminated do
if event.waitFor(0xFFFFFFFF) ~= wrSignaled then break end
if t.Terminated then break end
-- your code here
doKeyPress(69)
doKeyPress(22531)
end
event.destroy()
if myScriptStuff then myScriptStuff.event = nil end
end)
{$asm}
// your other code
// ...
{$luacode}
myScriptStuff.event.setEvent()
{$asm}
// ...
[DISABLE]
{$lua}
if syntaxcheck then return end
if myScriptStuff then
myScriptStuff.thread.terminate()
if myScriptStuff.event then
myScriptStuff.event.setEvent()
end
myScriptStuff = nil
end
{$asm}
// ... |
_________________ I don't know where I'm going, but I'll figure it out when I get there.
|
|