Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local storage
- function createsettings()
- local settings={}
- print("Number of Storage:")
- settings[1]="s"..read()
- save(settings,"settings.txt")
- end
- function loadsettings()
- local settings=load("settings.txt")
- storage=settings[1]
- end
- function save(table,name)
- local file = fs.open(name,"w")
- file.write(textutils.serialize(table))
- file.close()
- end
- function load(name)
- local file = fs.open(name,"r")
- local data = file.readAll()
- file.close()
- return textutils.unserialize(data)
- end
- function exist(name)
- file=io.open(name)
- if file~=nil then io.close(file) return true else return false end
- end
- -----------------------------
- redstone.setOutput("bottom",false)
- if not exist("settings.txt") then
- createsettings()
- end
- loadsettings()
- rednet.open("back")
- if exist("changes") then redstone.setOutput("bottom",true) end
- while true do
- local id, mens, protocol =rednet.receive()
- if protocol =="changesAntena"..storage then
- local changes={" "}
- if exist("changes") then
- changes=load("changes")
- end
- local newchanges=textutils.unserialize(mens)
- for i=1,#newchanges do
- changes[#changes+1]=newchanges[i]
- end
- save(changes,"changes")
- redstone.setOutput("bottom",true)
- rednet.send(id,"ok","changesAntenaReceived"..storage)
- end
- if protocol=="AskChangesAntena"..storage then
- local changes={" "}
- if exist("changes") then
- changes=load("changes")
- end
- rednet.send(id,textutils.serialize(changes),"changes"..storage)
- fs.delete("changes")
- redstone.setOutput("bottom",false)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement