Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local monitors = {peripheral.find('monitor')}
- local monitorvars = {}
- local orders = {}
- for i,v in ipairs(monitors) do
- v.setTextScale(1)
- v.setBackgroundColor(colors.white)
- v.clear()
- local width, height = v.getSize()
- v.setBackgroundColor(colors.yellow)
- v.setCursorPos(1,1)
- v.setTextColor(colors.black)
- v.write(' Order Station ')
- v.setBackgroundColor(colors.lightGray)
- v.setTextColor(colors.gray)
- v.setCursorPos(2,8)
- v.write('Submit')
- v.setCursorPos(9,8)
- v.setTextColor(colors.black)
- v.setBackgroundColor(colors.red)
- v.write('Clear')
- v.setCursorPos(2,2)
- v.setTextColor(colors.black)
- v.setBackgroundColor(colors.orange)
- v.write('Burger')
- v.setCursorPos(2,4)
- v.write('Fries')
- v.setCursorPos(2,6)
- v.write('Drink')
- v.setCursorPos(9,2)
- v.write('Nuggets')
- v.setCursorPos(9,4)
- v.write('Burrito')
- v.setBackgroundColor(colors.black)
- for x = 1,16 do
- for y = 1,9 do
- v.setCursorPos(x+1,y+9)
- v.write(' ')
- end
- end
- end
- local count = 0
- function monitormanager()
- while true do
- local ev = {os.pullEvent('monitor_touch')}
- if monitorvars[ev[2]] == nil then
- monitorvars[ev[2]] = {}
- end
- local m = peripheral.wrap(ev[2])
- local width, height = m.getSize()
- if ev[4] > 9 then
- if monitorvars[ev[2]][ev[4]-9] then
- table.remove(monitorvars[ev[2]],ev[4]-9)
- end
- end
- if ev[3] >= 2 and ev[3] <= 7 and ev[4] == 2 then
- table.insert(monitorvars[ev[2]],'Burger')
- end
- if ev[3] >= 2 and ev[3] <= 6 and ev[4] == 4 then
- table.insert(monitorvars[ev[2]],'Fries')
- end
- if ev[3] >= 2 and ev[3] <= 6 and ev[4] == 6 then
- table.insert(monitorvars[ev[2]],'Drink')
- end
- if ev[3] >= 9 and ev[3] <= 15 and ev[4] == 2 then
- table.insert(monitorvars[ev[2]],'Nuggets')
- end
- if ev[3] >= 9 and ev[3] <= 15 and ev[4] == 4 then
- table.insert(monitorvars[ev[2]],'Burrito')
- end
- if ev[3] >= 9 and ev[3] <= 13 and ev[4] == 8 then
- monitorvars[ev[2]] = {}
- end
- local msg = false
- local newtable = nil
- if ev[3] >= 2 and ev[3] <= 7 and ev[4] == 8 and #monitorvars[ev[2]] > 0 then
- newtable = monitorvars[ev[2]]
- monitorvars[ev[2]] = {}
- m.setBackgroundColor(colors.black)
- for x = 2,17 do
- for y = 10,18 do
- m.setCursorPos(x,y)
- m.write(' ')
- end
- end
- m.setCursorPos(2,10)
- m.setTextColor(colors.green)
- msg = true
- end
- if #monitorvars[ev[2]] > 9 then
- table.remove(monitorvars[ev[2]],10)
- end
- --order display
- m.setBackgroundColor(colors.black)
- for x = 2,17 do
- for y = 10,18 do
- m.setCursorPos(x,y)
- m.write(' ')
- end
- end
- m.setTextColor(colors.white)
- for i,v in ipairs(monitorvars[ev[2]]) do
- m.setCursorPos(2,i+9)
- m.write(v)
- end
- if msg then
- msg = false
- m.setTextColor(colors.green)
- m.setCursorPos(2,10)
- m.write('Your order has')
- m.setCursorPos(2,11)
- m.write('been Submitted!')
- m.setCursorPos(2,12)
- m.setTextColor(colors.yellow)
- m.write('Order number:')
- count = count + 1
- if count == 99 then
- count = 1
- end
- m.setCursorPos(2,13)
- m.write(string.sub(tostring(count),1,-1))
- table.insert(newtable,1,count)
- table.insert(orders,newtable)
- end
- --button color
- m.setCursorPos(2,8)
- if #monitorvars[ev[2]] > 0 then
- m.setTextColor(colors.black)
- m.setBackgroundColor(colors.blue)
- else
- m.setTextColor(colors.gray)
- m.setBackgroundColor(colors.lightGray)
- end
- m.write('Submit')
- end
- end
- function display()
- term.setCursorPos(2,17)
- term.setBackgroundColor(colors.blue)
- term.setTextColor(colors.white)
- write('Done')
- term.setCursorPos(7,17)
- term.setBackgroundColor(colors.green)
- write('Refresh')
- while true do
- local ev = {os.pullEvent('mouse_click')}
- local refresh = false
- if ev[3] >= 2 and ev[3] <= 5 and ev[4] == 17 then
- table.remove(orders,1)
- refresh = true
- end
- if (ev[3] >= 7 and ev[3] <= 13 and ev[4] == 17) or refresh then
- refresh = false
- paintutils.drawFilledBox(1,2,51,13,colors.black)
- if orders[1] then
- for i,v in ipairs(orders[1]) do
- if i == 1 then
- term.setBackgroundColor(colors.black)
- term.setCursorPos(2,3)
- term.setTextColor(colors.orange)
- term.write('---Order number '..v..'---')
- else
- term.setBackgroundColor(colors.black)
- term.setCursorPos(2,i+3)
- term.setTextColor(colors.green)
- term.write('> '..v)
- end
- end
- end
- end
- end
- end
- function totaldisplay()
- while true do
- sleep()
- term.setCursorPos(1,1)
- term.setTextColor(colors.yellow)
- term.setBackgroundColor(colors.black)
- write('Total orders: '..#orders..' ')
- if #orders > 0 then
- redstone.setOutput('top',true)
- else
- redstone.setOutput('top',false)
- end
- end
- end
- parallel.waitForAll(monitormanager,display,totaldisplay)
Add Comment
Please, Sign In to add comment