Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local databaseFile = "disk/shops.skydb"
- local adminPassword = "PVSfVF"
- local m = peripheral.find("monitor")
- local monX,monY = m.getSize()
- local function save(tbl,name)
- local file = fs.open(name,"w")
- file.write(textutils.serialise(tbl))
- file.close()
- end
- local function load(name)
- local file = fs.open(name,"r")
- local data = file.readAll()
- file.close()
- return textutils.unserialise(data)
- end
- local function centerText(text,y
- local x = math.floor(monX/2) - math.floor(string.len(text)/2)
- m.setCursorPos(x,y)
- m.write(text)
- end
- database = load(databaseFile)
- numData = #database
- cpn = 1
- dataWriting = false
- local function checkCurNumber()
- if cpn > numData then cpn = numData end
- if cpn < 1 then cpn = 1 end
- end
- local function handleTouch()
- while true do
- local _,x,y = os.pullEvent("monitor_touch")
- if x == 1 and y == 1 then cpn = cpn - 1 m.clear() end
- if x == monX and y == 1 then cpn = cpn + 1 m.clear() end
- end
- end
- local function main()
- while true do
- m.setCursorPos(1,1)
- m.setBackgroundColour(colours.blue)
- m.clearLine()
- m.setTextColour(colours.white)
- centerText(tostring(cpn) .. "/" .. tostring(numData),1)
- m.setCursorPos(1,1)
- m.write("<")
- m.setCursorPos(monX,1)
- m.write(">")
- m.setBackgroundColour(colours.black)
- checkCurNumber()
- if database[cpn] ~= nil then
- m.setTextColour(colours.red)
- centerText("Owner: "..database[cpn]["owner"],2)
- m.setTextColour(colours.yellow)
- centerText("Name: "..database[cpn]["name"],3)
- m.setTextColour(colours.white)
- m.setCursorPos(1,4)
- print(database[cpn]["desc"])
- end
- sleep(0.1)
- end
- end
- m.clear()
- parallel.waitForAny(handleKeys,main)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement