SHOW:
|
|
- or go back to the newest paste.
| 1 | local monitors = {peripheral.find('monitor')}
| |
| 2 | ||
| 3 | local monitorvars = {}
| |
| 4 | local orders = {}
| |
| 5 | ||
| 6 | for i,v in ipairs(monitors) do | |
| 7 | v.setTextScale(1) | |
| 8 | v.setBackgroundColor(colors.white) | |
| 9 | v.clear() | |
| 10 | local width, height = v.getSize() | |
| 11 | v.setBackgroundColor(colors.yellow) | |
| 12 | v.setCursorPos(1,1) | |
| 13 | v.setTextColor(colors.black) | |
| 14 | v.write(' Order Station ')
| |
| 15 | v.setBackgroundColor(colors.lightGray) | |
| 16 | v.setTextColor(colors.gray) | |
| 17 | v.setCursorPos(2,8) | |
| 18 | v.write('Submit')
| |
| 19 | v.setCursorPos(9,8) | |
| 20 | v.setTextColor(colors.black) | |
| 21 | v.setBackgroundColor(colors.red) | |
| 22 | v.write('Clear')
| |
| 23 | v.setCursorPos(2,2) | |
| 24 | v.setTextColor(colors.black) | |
| 25 | v.setBackgroundColor(colors.orange) | |
| 26 | v.write('Burger')
| |
| 27 | v.setCursorPos(2,4) | |
| 28 | v.write('Fries')
| |
| 29 | v.setCursorPos(2,6) | |
| 30 | v.write('Drink')
| |
| 31 | v.setCursorPos(9,2) | |
| 32 | v.write('Nuggets')
| |
| 33 | v.setCursorPos(9,4) | |
| 34 | v.write('Burrito')
| |
| 35 | v.setBackgroundColor(colors.black) | |
| 36 | for x = 1,16 do | |
| 37 | for y = 1,9 do | |
| 38 | v.setCursorPos(x+1,y+9) | |
| 39 | v.write(' ')
| |
| 40 | end | |
| 41 | end | |
| 42 | end | |
| 43 | ||
| 44 | local count = 0 | |
| 45 | ||
| 46 | function monitormanager() | |
| 47 | while true do | |
| 48 | local ev = {os.pullEvent('monitor_touch')}
| |
| 49 | if monitorvars[ev[2]] == nil then | |
| 50 | monitorvars[ev[2]] = {}
| |
| 51 | end | |
| 52 | local m = peripheral.wrap(ev[2]) | |
| 53 | local width, height = m.getSize() | |
| 54 | ||
| 55 | if ev[4] > 9 then | |
| 56 | if monitorvars[ev[2]][ev[4]-9] then | |
| 57 | table.remove(monitorvars[ev[2]],ev[4]-9) | |
| 58 | end | |
| 59 | end | |
| 60 | ||
| 61 | if ev[3] >= 2 and ev[3] <= 7 and ev[4] == 2 then | |
| 62 | table.insert(monitorvars[ev[2]],'Burger') | |
| 63 | end | |
| 64 | if ev[3] >= 2 and ev[3] <= 6 and ev[4] == 4 then | |
| 65 | table.insert(monitorvars[ev[2]],'Fries') | |
| 66 | end | |
| 67 | if ev[3] >= 2 and ev[3] <= 6 and ev[4] == 6 then | |
| 68 | table.insert(monitorvars[ev[2]],'Drink') | |
| 69 | end | |
| 70 | if ev[3] >= 9 and ev[3] <= 15 and ev[4] == 2 then | |
| 71 | table.insert(monitorvars[ev[2]],'Nuggets') | |
| 72 | end | |
| 73 | if ev[3] >= 9 and ev[3] <= 15 and ev[4] == 4 then | |
| 74 | table.insert(monitorvars[ev[2]],'Burrito') | |
| 75 | end | |
| 76 | if ev[3] >= 9 and ev[3] <= 13 and ev[4] == 8 then | |
| 77 | monitorvars[ev[2]] = {}
| |
| 78 | end | |
| 79 | ||
| 80 | local msg = false | |
| 81 | local newtable = nil | |
| 82 | ||
| 83 | if ev[3] >= 2 and ev[3] <= 7 and ev[4] == 8 and #monitorvars[ev[2]] > 0 then | |
| 84 | newtable = monitorvars[ev[2]] | |
| 85 | monitorvars[ev[2]] = {}
| |
| 86 | m.setBackgroundColor(colors.black) | |
| 87 | for x = 2,17 do | |
| 88 | for y = 10,18 do | |
| 89 | m.setCursorPos(x,y) | |
| 90 | m.write(' ')
| |
| 91 | end | |
| 92 | end | |
| 93 | m.setCursorPos(2,10) | |
| 94 | m.setTextColor(colors.green) | |
| 95 | msg = true | |
| 96 | end | |
| 97 | ||
| 98 | if #monitorvars[ev[2]] > 9 then | |
| 99 | table.remove(monitorvars[ev[2]],10) | |
| 100 | end | |
| 101 | ||
| 102 | --order display | |
| 103 | m.setBackgroundColor(colors.black) | |
| 104 | for x = 2,17 do | |
| 105 | for y = 10,18 do | |
| 106 | m.setCursorPos(x,y) | |
| 107 | m.write(' ')
| |
| 108 | end | |
| 109 | end | |
| 110 | ||
| 111 | m.setTextColor(colors.white) | |
| 112 | ||
| 113 | for i,v in ipairs(monitorvars[ev[2]]) do | |
| 114 | m.setCursorPos(2,i+9) | |
| 115 | m.write(v) | |
| 116 | end | |
| 117 | ||
| 118 | if msg then | |
| 119 | msg = false | |
| 120 | m.setTextColor(colors.green) | |
| 121 | m.setCursorPos(2,10) | |
| 122 | m.write('Your order has')
| |
| 123 | m.setCursorPos(2,11) | |
| 124 | m.write('been Submitted!')
| |
| 125 | m.setCursorPos(2,12) | |
| 126 | m.setTextColor(colors.yellow) | |
| 127 | m.write('Order number:')
| |
| 128 | count = count + 1 | |
| 129 | if count == 99 then | |
| 130 | count = 1 | |
| 131 | end | |
| 132 | m.setCursorPos(2,13) | |
| 133 | m.write(string.sub(tostring(count),1,-1)) | |
| 134 | table.insert(newtable,1,count) | |
| 135 | table.insert(orders,newtable) | |
| 136 | end | |
| 137 | ||
| 138 | --button color | |
| 139 | m.setCursorPos(2,8) | |
| 140 | if #monitorvars[ev[2]] > 0 then | |
| 141 | m.setTextColor(colors.black) | |
| 142 | m.setBackgroundColor(colors.blue) | |
| 143 | else | |
| 144 | m.setTextColor(colors.gray) | |
| 145 | m.setBackgroundColor(colors.lightGray) | |
| 146 | end | |
| 147 | m.write('Submit')
| |
| 148 | end | |
| 149 | end | |
| 150 | ||
| 151 | function display() | |
| 152 | term.setCursorPos(2,17) | |
| 153 | term.setBackgroundColor(colors.blue) | |
| 154 | term.setTextColor(colors.white) | |
| 155 | write('Done')
| |
| 156 | term.setCursorPos(7,17) | |
| 157 | term.setBackgroundColor(colors.green) | |
| 158 | write('Refresh')
| |
| 159 | while true do | |
| 160 | local ev = {os.pullEvent('mouse_click')}
| |
| 161 | local refresh = false | |
| 162 | if ev[3] >= 2 and ev[3] <= 5 and ev[4] == 17 then | |
| 163 | table.remove(orders,1) | |
| 164 | refresh = true | |
| 165 | end | |
| 166 | if (ev[3] >= 7 and ev[3] <= 13 and ev[4] == 17) or refresh then | |
| 167 | refresh = false | |
| 168 | paintutils.drawFilledBox(1,2,51,13,colors.black) | |
| 169 | if orders[1] then | |
| 170 | for i,v in ipairs(orders[1]) do | |
| 171 | if i == 1 then | |
| 172 | term.setBackgroundColor(colors.black) | |
| 173 | term.setCursorPos(2,3) | |
| 174 | term.setTextColor(colors.orange) | |
| 175 | term.write('---Order number '..v..'---')
| |
| 176 | else | |
| 177 | term.setBackgroundColor(colors.black) | |
| 178 | term.setCursorPos(2,i+3) | |
| 179 | term.setTextColor(colors.green) | |
| 180 | term.write('> '..v)
| |
| 181 | end | |
| 182 | end | |
| 183 | end | |
| 184 | end | |
| 185 | end | |
| 186 | end | |
| 187 | ||
| 188 | function totaldisplay() | |
| 189 | while true do | |
| 190 | sleep() | |
| 191 | term.setCursorPos(1,1) | |
| 192 | term.setTextColor(colors.yellow) | |
| 193 | term.setBackgroundColor(colors.black) | |
| 194 | write('Total orders: '..#orders..' ')
| |
| 195 | if #orders > 0 then | |
| 196 | redstone.setOutput('top',true)
| |
| 197 | else | |
| 198 | redstone.setOutput('top',false)
| |
| 199 | end | |
| 200 | end | |
| 201 | end | |
| 202 | ||
| 203 | parallel.waitForAll(monitormanager,display,totaldisplay) |