Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function show()
- term.clear()
- term.setCursorPos(1, 1)
- for slot = 1, 5 do
- if mytable[slot] ~= 0 then
- print("Objednavka je: " .. mytable[slot][1] .. "x " .. mytable[slot][2] .. " za " .. mytable[slot][3] .. " kreditu.")
- print("Cilovym podnikem je " .. mytable[slot][6] .. ".")
- print(" ----------------------------------------")
- else print("volno")
- end
- end
- end
- -- core
- if fs.exists("tabledata") then
- fileH = fs.open("tabledata", "r")
- dataTL = fileH.readAll()
- fileH.close()
- mytable = textutils.unserialize(dataTL)
- show()
- else mytable = {}
- mytable[1] = 0 -- kolikrat
- mytable[2] = 0 -- co
- mytable[3] = 0 -- cena
- mytable[4] = 0 -- ID restaurace
- mytable[5] = 0 -- F nebo M
- mytable[6] = 0 -- podnik
- end
- rednet.open("top")
- while true do
- local id, msg, protocol = rednet.receive("offer")
- temp = textutils.unserialize(msg)
- if temp[5] == "F" then
- if mytable[1] ~= 0 and
- mytable[1][4] == temp[4] then
- mytable[1] = 0
- fileHS = fs.open("tabledata", "w")
- fileHS.write(textutils.serialize(mytable))
- fileHS.close()
- fileH = fs.open("tabledata", "r")
- dataTL = fileH.readAll()
- fileH.close()
- mytable = textutils.unserialize(dataTL)
- show()
- elseif mytable[2] ~= 0 and
- mytable[2][4] == temp[4] then
- mytable[2] = 0
- fileHS = fs.open("tabledata", "w")
- fileHS.write(textutils.serialize(mytable))
- fileHS.close()
- fileH = fs.open("tabledata", "r")
- dataTL = fileH.readAll()
- fileH.close()
- mytable = textutils.unserialize(dataTL)
- show()
- elseif mytable[1] == 0 then
- mytable[1] = textutils.unserialize(msg)
- fileHS = fs.open("tabledata", "w")
- fileHS.write(textutils.serialize(mytable))
- fileHS.close()
- fileH = fs.open("tabledata", "r")
- dataTL = fileH.readAll()
- fileH.close()
- mytable = textutils.unserialize(dataTL)
- show()
- elseif mytable[2] == 0 then
- mytable[2] = textutils.unserialize(msg)
- fileHS = fs.open("tabledata", "w")
- fileHS.write(textutils.serialize(mytable))
- fileHS.close()
- fileH = fs.open("tabledata", "r")
- dataTL = fileH.readAll()
- fileH.close()
- mytable = textutils.unserialize(dataTL)
- show()
- else rednet.open("top")
- rednet.send(temp[4], "full")
- end
- elseif temp[5] == "M" then
- if mytable[3] ~= 0 and
- mytable[3][4] == temp[4] then
- mytable[3] = 0
- fileHS = fs.open("tabledata", "w")
- fileHS.write(textutils.serialize(mytable))
- fileHS.close()
- fileH = fs.open("tabledata", "r")
- dataTL = fileH.readAll()
- fileH.close()
- mytable = textutils.unserialize(dataTL)
- show()
- elseif mytable[4] ~= 0 and
- mytable[4][4] == temp[4] then
- mytable[4] = 0
- fileHS = fs.open("tabledata", "w")
- fileHS.write(textutils.serialize(mytable))
- fileHS.close()
- fileH = fs.open("tabledata", "r")
- dataTL = fileH.readAll()
- fileH.close()
- mytable = textutils.unserialize(dataTL)
- show()
- elseif mytable[5] ~= 0 and
- mytable[5][4] == temp[4] then
- mytable[5] = 0
- fileHS = fs.open("tabledata", "w")
- fileHS.write(textutils.serialize(mytable))
- fileHS.close()
- fileH = fs.open("tabledata", "r")
- dataTL = fileH.readAll()
- fileH.close()
- mytable = textutils.unserialize(dataTL)
- show()
- elseif mytable[3] == 0 then
- mytable[3] = textutils.unserialize(msg)
- fileHS = fs.open("tabledata", "w")
- fileHS.write(textutils.serialize(mytable))
- fileHS.close()
- fileH = fs.open("tabledata", "r")
- dataTL = fileH.readAll()
- fileH.close()
- mytable = textutils.unserialize(dataTL)
- show()
- elseif mytable[4] == 0 then
- mytable[4] = textutils.unserialize(msg)
- fileHS = fs.open("tabledata", "w")
- fileHS.write(textutils.serialize(mytable))
- fileHS.close()
- fileH = fs.open("tabledata", "r")
- dataTL = fileH.readAll()
- fileH.close()
- mytable = textutils.unserialize(dataTL)
- show()
- elseif mytable[5] == 0 then
- mytable[5] = textutils.unserialize(msg)
- fileHS = fs.open("tabledata", "w")
- fileHS.write(textutils.serialize(mytable))
- fileHS.close()
- fileH = fs.open("tabledata", "r")
- dataTL = fileH.readAll()
- fileH.close()
- mytable = textutils.unserialize(dataTL)
- show()
- end
- end
- end
Add Comment
Please, Sign In to add comment