Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- color = { 0 }
- name = { 0 }
- ids = { 59 }
- function tclear(x,y)
- if x == nil then
- x = 1
- end
- if y == nil then
- y = 1
- end
- term.clear()
- term.setCursorPos(x,y)
- end
- function tablelength(T)
- local count = 0
- for _ in pairs(T) do count = count + 1 end
- return count
- end
- function load(name)
- local file = fs.open(name,"r")
- local data = file.readAll()
- file.close()
- return textutils.unserialize(data)
- end
- function save(table,name)
- local file = fs.open(name,"w")
- file.write(textutils.serialize(table))
- file.close()
- end
- -------------FUNCTIONS
- tclear()
- fs.makeDir("saves")
- if fs.exists("saves/colors") ~= true then
- save(color,"saves/colors")
- save(name, "saves/name")
- end
- rednet.open("right")
- for i = 1, tablelength(ids) do
- print(color)
- rednet.send(ids[i], color)
- rednet.send(ids[i], name)
- end
- while true do
- color = load("saves/colors")
- name = load("saves/name")
- for i = 1, tablelength(ids) do
- rednet.send(ids[i], color)
- rednet.send(ids[i], name)
- end
- local senderId, message, distance = rednet.receive()
- if string.find(message, "color", 1) ~= nil then
- message = string.sub(message,6,string.len(message))
- table.insert(color, message)
- save(color, "saves/colors")
- else
- table.insert(name, message)
- save(name, "saves/name")
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment