This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
fuze's profile picture

[Lua] Run code on termination

Started by fuze, 27 December 2012 - 07:30 AM
fuze #1
Posted 27 December 2012 - 08:30 AM
I want my program to run some code when it is terminated. I created some code that does that but it can't do anything else than wait for the 'terminate' event..
Here is the code: http://pastebin.com/12puJ6WW

I'm kind of a noob when it comes to Lua..
remiX #2
Posted 27 December 2012 - 08:44 AM
while true do
    event, p1, p2, p3 = os.pullEvent()
    if event == "terminate" then
        -- If someone attempts to terminate
    end
end
Lyqyd #3
Posted 27 December 2012 - 08:46 AM
You'll need to use os.pullEventRaw to catch the terminate event.