Savage_Me55iah

CC_API_eventmanip

Jul 19th, 2017
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.34 KB | None | 0 0
  1. --Script by Savage_Me55iah of CraftAU.com.au--
  2.  
  3. --Other Savage_Me55iah scripts @ http://pastebin.com/u/Savage_Me55iah
  4.  
  5. --INSTRUCTIONS ON USE--
  6. --Instruction video on http://youtube.com/savagemessiah5
  7.  
  8. --Contact Savage_Me55iah @ CraftAU.com.au or http://www.computercraft.info/forums2/ with suggestions/fixes/bugs
  9.  
  10. local scriptName = "eventmanip"
  11. fileDetail = fileDetail or {}
  12. fileDetail[scriptName] = {["version"] = 0.1, ["pastebin"] = "AijGThy5"}
  13.  
  14. local tArgs = {...}
  15. if tArgs[1] == "update" then
  16.     print("UPDATING") shell.run("pastebin get "..fileDetail[scriptName].pastebin.." "..scriptName.."_update")
  17.     if fs.exists(scriptName.."_update") then fs.remove(shell.getRunningProgram()) fs.copy(scriptName.."_update", shell.getRunningProgram()) fs.remove(scriptName.."_update") print("UPDATE SUCCESS") else print("UPDATE FAILED") end
  18. end
  19.  
  20. -----------------------------------------------------------------------------------------------------------
  21. -- Variables --
  22. -----------------------------------------------------------------------------------------------------------
  23.  
  24. eventFunction = {}
  25.  
  26. -----------------------------------------------------------------------------------------------------------
  27. -- API Functions --
  28. -----------------------------------------------------------------------------------------------------------
  29.  
  30. -- event = eventmanip.filter(functionNum, {string, string, etc}) -- [1] returns function ran correctly [2] returns result
  31. -- will shift an numerical table, up > down
  32. function filter(param_functionNum, param_events)
  33.     local result, functionNum, list, event = {false, false}, param_functionNum.."/002", {}, {false}
  34.     if booleanmanip.variableCheck(functionNum, {"table"}, {param_events})[2] then
  35.         for a,b in pairs(param_events) do list[b] = true end
  36.         while not booleanmanip.check(functionNum, list[event[1]])[1] do
  37.             event = {os.pullEvent()}
  38.         end
  39.         logger.logger(functionNum, {"EventFilter Triggered:", event}, 0, " ")
  40.     else
  41.         logger.logger(functionNum, {"Function Error, Expected: event = eventmanip.filter(functionNum, {string, string, etc})"}, 2, " ")
  42.     end
  43.     return event
  44. end
  45.  
  46. -----------------------------------------------------------------------------------------------------------
  47. -- Old Functions --
  48. -----------------------------------------------------------------------------------------------------------
Advertisement
Add Comment
Please, Sign In to add comment