Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local monitor = peripheral.find("monitor")
- local previousValue, currentValue = 0,0
- local width, height = term.getSize()
- -- This has to be the amount of diamonds inserted into an inventory, the playes bet in other words
- local maxAmount = 3
- function main()
- if (monitor ~= nil) then
- term.redirect(monitor)
- width, height = term.getSize()
- end
- term.clear()
- paintutils.drawLine(1, math.ceil(height/2), width, math.ceil(height/2), colors.lightGray)
- --math.randomseed(os.time())
- for i=1,height do
- term.setCursorPos(1, i)
- local value = math.ceil(height/2)-i
- term.write(value)
- end
- for x=1,width do
- local increment = math.random(-1,1)
- previousValue = currentValue
- currentValue = currentValue + increment
- local currentY = currentValue+math.ceil(height/2)
- local previousY = previousValue+math.ceil(height/2)
- local color = colors.gray
- if (currentY < math.ceil(height/2)) then
- color = colors.green
- elseif (currentY > math.ceil(height/2)) then
- color = colors.red
- end
- --paintutils.drawLine(x-1, previousY, x, currentY, color)
- paintutils.drawPixel(x, currentY, color)
- sleep(0.1)
- end
- -- clamp value depending on the amount inserted
- if (currentValue > maxAmount) then
- currentValue = maxAmount
- elseif (currentValue < -maxAmount) then
- currentValue = -maxAmount
- end
- currentValue = -currentValue
- term.setCursorPos(width/2,1)
- paintutils.drawPixel(width/2,1, colors.black)
- print("Value: " .. currentValue)
- end
- main()
Advertisement
Add Comment
Please, Sign In to add comment