Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- white = 0
- orange = 0
- magenta = 0
- ltBlue = 0
- totale = 0
- local function drawPixelInternal(xPos, yPos)
- term.setCursorPos(xPos, yPos)
- term.write(" ")
- end
- local tColourLookup = {}
- for n = 1, 16 do
- tColourLookup[string.byte("0123456789abcdef", n, n)] = 2 ^ (n - 1)
- end
- function drawFilledBox(startX, startY, endX, endY, nColour)
- if type(startX) ~= "number" or type(startX) ~= "number" or type(endX) ~=
- "number" or type(endY) ~= "number" or
- (nColour ~= nil and type(nColour) ~= "number") then
- error("Expected startX, startY, endX, endY, colour", 2)
- end
- startX = math.floor(startX)
- startY = math.floor(startY)
- endX = math.floor(endX)
- endY = math.floor(endY)
- if nColour then term.setBackgroundColor(nColour) end
- if startX == endX and startY == endY then
- drawPixelInternal(startX, startY)
- return
- end
- local minX = math.min(startX, endX)
- if minX == startX then
- minY = startY
- maxX = endX
- maxY = endY
- else
- minY = endY
- maxX = startX
- maxY = startY
- end
- for x = minX, maxX do for y = minY, maxY do drawPixelInternal(x, y) end end
- end
- function finish()
- term.clear()
- end
- -- CAE :
- function clear()
- term.clear()
- drawFilledBox(18, 12, 34, 14, colors.yellow)
- term.setCursorPos(22, 13)
- term.setTextColor(colors.black)
- term.write("HO FINITO")
- term.setBackgroundColor(colors.black)
- term.setTextColor(colors.white)
- term.setCursorPos(1, 1)
- term.write("Oggetti contati: 0")
- end
- clear()
- while true do
- os.pullEvent("redstone")
- col = rs.getBundledInput("bottom")
- if colors.test(col, colors.orange) then
- orange = orange + 32
- end
- if colors.test(col, colors.magenta) then
- magenta = magenta + 32
- end
- if colors.test(col, colors.lightBlue) then
- ltBlue = ltBlue + 2
- end
- if colors.test(col, colors.white) then
- white = white + 32
- end
- clear()
- term.setCursorPos(1, 1)
- totale = orange+magenta+ltBlue+white
- print("Oggetti contati: "..totale)
- local myTimer = os.startTimer(1)
- local event, par1, x, y = os.pullEvent("mouse_click")
- if event == "mouse_click" and y > 12 and y < 14 and x > 18 and x < 34 then
- finish()
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement