Difference between revisions of "Terminate (event)"

From ComputerCraft Wiki
Jump to: navigation, search
m
m
Line 7: Line 7:
 
{{Example
 
{{Example
 
|desc=This overides the [[os.pullEvent]] function to display a custom message when a program is terminated
 
|desc=This overides the [[os.pullEvent]] function to display a custom message when a program is terminated
|code=function os.pullEvent(_sFilter)
+
|code= function os.pullEvent(_sFilter)
 
   local event = { os.pullEventRaw(_sFilter) }
 
   local event = { os.pullEventRaw(_sFilter) }
  if event[1] == "terminate" then
+
    if event[1] == "terminate" then
    error("Terminate Event Found", 0)
+
      error("Terminate Event Found", 0)
 +
    end
 +
    return unpack(event)
 
   end
 
   end
  return unpack(event)
 
end
 
 
}}
 
}}

Revision as of 22:44, 27 March 2013

This page needs some serious TLC, stat!
Please help us by cleaning it, fixing it up, or sparing it some love.
(Reason: A demonstration on the use and handling of this event would be beneficial. AfterLifeLochie 16:13, 30 November 2012 (MSK))



Grid Modem.png  Event terminate
Fired when CTRL+T is held to terminate the running program.
Returned Object 1 Nothing


Grid paper.png  Example
This overides the os.pullEvent function to display a custom message when a program is terminated
Code
function os.pullEvent(_sFilter)
 local event = { os.pullEventRaw(_sFilter) }
   if event[1] == "terminate" then
     error("Terminate Event Found", 0)
   end
   return unpack(event)
 end