Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local events, count = {[1] = {"Event Printer Output file",
- "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
- local map = {
- --CC events
- char = {
- "character"
- },
- key = {
- "key",
- "is_held"
- },
- key_up = {
- "key"
- },
- paste = {
- "paste_data"
- },
- timer = {
- "timer_data"
- },
- alarm = {
- "alarm_data"
- },
- task_complete = {
- "numberTaskID",
- "boolSuccess",
- "stringError",
- "anyParam"
- },
- redstone = {}, --No data to return
- terminate = {}, --No data to return
- disk = {
- "side"
- },
- disk_eject = {
- "side"
- },
- peripheral = {
- "side"
- },
- peripheral_detach = {
- "side"
- },
- rednet_message = {
- "senderID",
- "message",
- "protocol"
- }
- }
- local requiredCoreFuncs = {
- "findPeripheralOnSide",
- }
- local function httpGet(stringURL,stringFileNameToSaveTo)
- local h, err = http.get(stringURL)
- if not h then printError(err) return end
- local f = fs.open(stringFileNameToSaveTo, "w")
- f.write(h.readAll())
- f.close()
- h.close()
- end
- if not fs.exists("apis/CGBCoreLib.lua") then
- if not httpGet("https://pastebin.com/raw/xuMVS2GP", "apis/CGBCoreLib.lua") then
- error("Error: Dependancy: 'CGBCoreLib' could not be downloaded. Please connect to the internet and restart")
- end
- end
- local core = require("apis/CGBCoreLib")
- for _,req in pairs(requiredCoreFuncs) do
- if not core[req] then
- if not httpGet("https://pastebin.com/raw/xuMVS2GP","apis/CGBCoreLib.lua") then
- error("Error: Dependancy: 'CGBCoreLib' is missing required functions and needs updating, please connect to the internet and try again")
- else
- os.reboot()
- end
- end
- end
- rednet.open(core.findPeripheralOnSide("modem"))
- local readInto
- readInto = function(t, evt)
- local name = evt[1]
- if map[name] then
- for i = 2, #evt do
- t[i] = {[map[name][i - 1]] = evt[i]}
- end
- else
- --return error("unrecognized event")
- print("Unrecognized event:")
- events[count] = evt
- end
- end
- while true do
- count = count + 1
- local event = {os.pullEvent()}
- events[count] = {{event = event[1]}}
- readInto(events[count], event)
- print(textutils.serialize(events[count]))
- core.saveConfig("data/events.lua",events)
- if event[4] == "topsecret" then
- --local test = os.startTimer(1)
- print("Top Secret Message received from: '" .. event[2] .. "'. Message Data: '" .. event[3] .. "'.")
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement