Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- online = "yes"
- local switches_id = "comp_id"
- local vault = "vault"
- local switches_id2 = "comp_id2"
- local vault2 = "vault2"
- local users = "whitelist"
- local owner = "owner_whitelist"
- local edit = "edit_whitelist"
- -- FUNCTIONS --
- function load_whitelists()
- chatter.say("Jarvis: Loading...", 200)
- local switches = nil
- local fileHandle = fs.open (switches_id, 'r')
- switches = textutils.unserialize (fileHandle.readAll())
- fileHandle.close()
- local owner_only = nil
- local fileHandle = fs.open (vault, 'r')
- owner_only = textutils.unserialize (fileHandle.readAll())
- fileHandle.close()
- local switchesid = nil
- local fileHandle = fs.open (switches_id2, 'r')
- switchesid = textutils.unserialize (fileHandle.readAll())
- fileHandle.close()
- local owner_onlyid = nil
- local fileHandle = fs.open (vault2, 'r')
- owner_onlyid = textutils.unserialize (fileHandle.readAll())
- fileHandle.close()
- local whitelist = nil
- local fileHandle = fs.open (users, 'r')
- whitelist = textutils.unserialize (fileHandle.readAll())
- fileHandle.close()
- local edit_whitelist = nil
- local fileHandle = fs.open (edit, 'r')
- edit_whitelist = textutils.unserialize (fileHandle.readAll())
- fileHandle.close()
- local owner_whitelist = nil
- local fileHandle = fs.open (owner, 'r')
- owner_whitelist = textutils.unserialize (fileHandle.readAll())
- fileHandle.close()
- chatter.say("Jarvis: Done sir", 200)
- end
- function save_whitelist()
- chatter.say("Jarvis: Adding...", 200)
- local fileHandle = fs.open (users, 'w')
- chatter.say("Jarvis: Saving...", 200)
- fileHandle.write (textutils.serialize (whitelist))
- fileHandle.close()
- chatter.say("Jarvis: Done sir", 200)
- load_whitelists()
- end
- function save_edit()
- chatter.say("Jarvis: Adding...", 200)
- local fileHandle = fs.open (edit, 'w')
- chatter.say("Jarvis: Saving...", 200)
- fileHandle.write (textutils.serialize (edit_whitelist))
- fileHandle.close()
- chatter.say("Jarvis: Done sir", 200)
- load_whitelists()
- end
- function save_owner()
- chatter.say("Jarvis: Adding...", 200)
- local fileHandle = fs.open (owner, 'w')
- chatter.say("Jarvis: Saving...", 200)
- fileHandle.write (textutils.serialize (owner_whitelist))
- fileHandle.close()
- chatter.say("Jarvis: Done sir", 200)
- load_whitelists()
- end
- function save_switches()
- chatter.say("Jarvis: Adding...", 200)
- local fileHandle = fs.open (switches_id, 'w')
- chatter.say("Jarvis: Saving...", 200)
- fileHandle.write (textutils.serialize (switches))
- fileHandle.close()
- chatter.say("Jarvis: Done sir", 200)
- chatter.say("Jarvis: Adding...", 200)
- local fileHandle = fs.open (switches_id2, 'w')
- chatter.say("Jarvis: Saving...", 200)
- fileHandle.write (textutils.serialize (switchesid))
- fileHandle.close()
- chatter.say("Jarvis: Done sir", 200)
- load_whitelists()
- end
- function save_vault()
- chatter.say("Jarvis: Adding...", 200)
- local fileHandle = fs.open (vault, 'w')
- chatter.say("Jarvis: Saving...", 200)
- fileHandle.write (textutils.serialize (owner_only))
- fileHandle.close()
- chatter.say("Jarvis: Done sir", 200)
- chatter.say("Jarvis: Adding...", 200)
- local fileHandle = fs.open (vault2, 'w')
- chatter.say("Jarvis: Saving...", 200)
- fileHandle.write (textutils.serialize (owner_onlyid))
- fileHandle.close()
- chatter.say("Jarvis: Done sir", 200)
- load_whitelists()
- end
- function clear()
- event = "blah"
- id = "blah"
- text = "blah"
- end
- local function findPeripheral( t, e )
- for _,side in pairs( rs.getSides() ) do
- if peripheral.getType( side ) == t then
- return peripheral.wrap( side )
- end
- end
- error("No "..(e or t).." attached to the computer", 0)
- end
- print("adding chat")
- local chatter = findPeripheral("chat", "chatbox")
- print("adding wireless")
- local rednet = findPeripheral("rednet", "rednet")
- print("done")
- function switch()
- rednet.send(id3, "switch")
- end
- function Event()
- local event, id, text = os.pullEventRaw("chat")
- id = id:lower()
- text = text:lower()
- if event == "chat" then
- if whitelist[id] then
- if switches[text] then
- chatter.say("Jarvis: confirmed sir", 200)
- id3 = switchesid[text]
- switch()
- end
- if text == "ill be leaving jarvis" then
- chatter.say("Jarvis: Until you return Master Savage, Security Lockdown", 200)
- online = "no"
- rednet.send(Monitor, "online_no")
- end
- if text == "i am here jarvis" then
- chatter.say("Jarvis: Welcome back Master Savage bringing systems releasing lockdown", 200)
- online = "yes"
- rednet.send(Monitor, "online_yes")
- end
- if text == "jarvis chart a course for mordor" then
- chatter.say("Jarvis: One doesn't simply walk into Mordor sir", 200)
- end
- if text == "dwarves" then
- chatter.say("Jarvis: Nobody tosses a dwarf sir", 200)
- end
- if text == "jarvis who is batman?" then
- chatter.say("Jarvis: I'm BATMAN!", 200)
- chatter.say("Jarvis: ...", 200)
- chatter.say("Jarvis: Sir", 200)
- end
- if edit_whitelist[id] then
- if text == "need to edit you jarvis" then
- chatter.say("Jarvis: oh ah I need maintence go ahead sir", 200)
- print("You can now edit me: "..fs.getName(shell.getRunningProgram()))
- return
- end
- elseif text == "jarvis add switch" then
- chatter.say("Jarvis: Yes sir state name then id, say >Jarvis clear< to cancel", 200)
- clear()
- repeat
- local event, id, text1 = os.pullEventRaw("chat")
- until edit_whitelist[id]
- repeat
- local event, id, text2 = os.pullEventRaw("chat")
- until edit_whitelist[id]
- if text ~= "jarvis clear" and text2 ~= "jarvis clear" then
- id2 = tonumber (text2)
- switches[text1] = true
- switchesid[text1] = id2
- save_switches()
- end
- elseif owner_whitelist[id] then
- if text == "jarvis add vault" then
- chatter.say("Jarvis: Yes sir state name then id, say >Jarvis clear< to cancel", 200)
- clear()
- repeat
- local event, id, text1 = os.pullEventRaw("chat")
- until owner_whitelist[id]
- repeat
- local event, id, text2 = os.pullEventRaw("chat")
- until owner_whitelist[id]
- if text ~= "jarvis clear" and text2 ~= "jarvis clear" then
- id2 = tonumber (text2)
- owner_only[text1] = true
- owner_onlyid[text1] = id2
- save_vault()
- end
- elseif text == "jarvis add to whitelist" then
- chatter.say("Jarvis: Yes sir who would you like to add to the Whitelist?", 200)
- clear()
- repeat
- local event, id, text = os.pullEventRaw("chat")
- until owner_whitelist[id]
- if text ~= "jarvis clear" then
- whitelist[text] = true
- save_whitelist()
- end
- elseif text == "jarvis add to edit" then
- chatter.say("Jarvis: Yes sir who would you like to add to the Edit List?", 200)
- clear()
- repeat
- local event, id, text = os.pullEventRaw("chat")
- until owner_whitelist[id]
- if text ~= "jarvis clear" then
- edit_whitelist[text] = true
- save_edit()
- end
- elseif text == "jarvis add to owner" then
- chatter.say("Jarvis: Yes sir am I to have another owner?", 200)
- clear()
- repeat
- local event, id, text = os.pullEventRaw("chat")
- until owner_whitelist[id]
- if text ~= "jarvis clear" then
- owner_whitelist[text] = true
- save_owner()
- end
- elseif text == "jarvis remove from whitelist" then
- clear()
- repeat
- local event, id, text = os.pullEventRaw("chat")
- until owner_whitelist[id]
- if text ~= "jarvis clear" then
- whitelist[text] = false
- save_whitelist()
- end
- elseif text == "jarvis remove from edit" then
- clear()
- repeat
- local event, id, text = os.pullEventRaw("chat")
- until owner_whitelist[id]
- if text ~= "jarvis clear" then
- edit_whitelist[text] = false
- save_edit()
- end
- elseif text == "jarvis remove from owner" then
- clear()
- repeat
- local event, id, text = os.pullEventRaw("chat")
- until owner_whitelist[id]
- if text ~= "jarvis clear" then
- owner_whitelist[text] = false
- save_owner()
- end
- end
- end
- end
- end
- end
- -- PROGRAM --
- load_whitelists()
- chatter.say("Welcome back to Craft Au sir", 200)
- while true do
- Event()
- end
Advertisement
Add Comment
Please, Sign In to add comment