paramus

Broker

Jun 23rd, 2026 (edited)
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.69 KB | Gaming | 0 0
  1. local monitor = peripheral.find("monitor")
  2. local previousValue, currentValue = 0,0
  3. local width, height = term.getSize()
  4.  
  5. -- This has to be the amount of diamonds inserted into an inventory, the playes bet in other words
  6. local maxAmount = 3
  7.  
  8. function main()
  9.     if (monitor ~= nil) then
  10.         term.redirect(monitor)
  11.         width, height = term.getSize()
  12.     end
  13.     term.clear()
  14.     paintutils.drawLine(1, math.ceil(height/2), width, math.ceil(height/2), colors.lightGray)
  15.     --math.randomseed(os.time())
  16.    
  17.     for i=1,height do
  18.         term.setCursorPos(1, i)
  19.        
  20.         local value = math.ceil(height/2)-i
  21.         term.write(value)
  22.     end
  23.    
  24.     for x=1,width do
  25.         local increment = math.random(-1,1)
  26.         previousValue = currentValue
  27.         currentValue = currentValue + increment
  28.        
  29.         local currentY = currentValue+math.ceil(height/2)
  30.         local previousY = previousValue+math.ceil(height/2)
  31.        
  32.         local color = colors.gray
  33.         if (currentY < math.ceil(height/2)) then
  34.             color = colors.green
  35.         elseif (currentY > math.ceil(height/2)) then
  36.             color = colors.red
  37.         end
  38.        
  39.         --paintutils.drawLine(x-1, previousY, x, currentY, color)
  40.         paintutils.drawPixel(x, currentY, color)
  41.         sleep(0.1)
  42.     end
  43.    
  44.     -- clamp value depending on the amount inserted
  45.     if (currentValue > maxAmount) then
  46.         currentValue = maxAmount
  47.     elseif (currentValue < -maxAmount) then
  48.         currentValue = -maxAmount
  49.     end
  50.    
  51.     currentValue = -currentValue
  52.     term.setCursorPos(width/2,1)
  53.     paintutils.drawPixel(width/2,1, colors.black)
  54.     print("Value: " .. currentValue)
  55. end
  56.  
  57. main()
Advertisement
Add Comment
Please, Sign In to add comment