Advertisement
CreeperNukeBoom

temporary

Apr 15th, 2020
767
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.53 KB | None | 0 0
  1. local events, count = {[1] = {"Event Printer Output file",
  2. "These names are representative only and by no means are what they are called: event[IsHeld] won't work unless it's coded in else it's event[3]"},}, 1
  3. local map = {
  4.   --CC events
  5.   char = {
  6.     "character"
  7.   },
  8.   key = {
  9.     "key",
  10.     "is_held"
  11.   },
  12.   key_up = {
  13.     "key"
  14.   },
  15.   paste = {
  16.     "paste_data"
  17.   },
  18.   timer = {
  19.     "timer_data"
  20.   },
  21.   alarm = {
  22.     "alarm_data"
  23.   },
  24.   task_complete = {
  25.     "numberTaskID",
  26.     "boolSuccess",
  27.     "stringError",
  28.     "anyParam"
  29.   },
  30.   redstone = {}, --No data to return
  31.   terminate = {}, --No data to return
  32.   disk = {
  33.     "side"
  34.   },
  35.   disk_eject = {
  36.     "side"
  37.   },
  38.   peripheral = {
  39.     "side"
  40.   },
  41.   peripheral_detach = {
  42.     "side"
  43.   },
  44.   rednet_message = {
  45.     "senderID",
  46.     "message",
  47.     "protocol"
  48.   }
  49. }
  50.  
  51. local requiredCoreFuncs = {
  52.   "findPeripheralOnSide",
  53. }
  54.  
  55. local function httpGet(stringURL,stringFileNameToSaveTo)
  56.   local h, err = http.get(stringURL)
  57.   if not h then printError(err) return end
  58.   local f = fs.open(stringFileNameToSaveTo, "w")
  59.   f.write(h.readAll())
  60.   f.close()
  61.   h.close()
  62. end
  63.  
  64. if not fs.exists("apis/CGBCoreLib.lua") then
  65.   if not httpGet("https://pastebin.com/raw/xuMVS2GP", "apis/CGBCoreLib.lua") then
  66.     error("Error: Dependancy: 'CGBCoreLib' could not be downloaded. Please connect to the internet and restart")
  67.   end
  68. end
  69.  
  70. local core = require("apis/CGBCoreLib")
  71.  
  72. for _,req in pairs(requiredCoreFuncs) do
  73.   if not core[req] then
  74.     if not httpGet("https://pastebin.com/raw/xuMVS2GP","apis/CGBCoreLib.lua") then
  75.       error("Error: Dependancy: 'CGBCoreLib' is missing required functions and needs updating, please connect to the internet and try again")
  76.     else
  77.       os.reboot()
  78.     end
  79.   end
  80. end
  81.  
  82. rednet.open(core.findPeripheralOnSide("modem"))
  83.  
  84. local readInto
  85. readInto = function(t, evt)
  86.   local name = evt[1]
  87.   if map[name] then
  88.     for i = 2, #evt do
  89.       t[i] = {[map[name][i - 1]] = evt[i]}
  90.     end
  91.   else
  92.     --return error("unrecognized event")
  93.     print("Unrecognized event:")
  94.     events[count] = evt
  95.   end
  96. end
  97. while true do
  98.   count = count + 1
  99.   local event = {os.pullEvent()}
  100.   events[count] = {{event = event[1]}}
  101.   readInto(events[count], event)
  102.   print(textutils.serialize(events[count]))
  103.   core.saveConfig("data/events.lua",events)
  104.   if event[4] == "topsecret" then
  105.     --local test = os.startTimer(1)
  106.     print("Top Secret Message received from: '" .. event[2] .. "'. Message Data: '" .. event[3] .. "'.")
  107.   end
  108. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement