Advertisement
massacring

WishingWellInstructions

Oct 1st, 2024 (edited)
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.35 KB | None | 0 0
  1. local monitor = peripheral.find("monitor")
  2. local width, height
  3.  
  4. local function setup()
  5.     monitor.setBackgroundColor(colors.black)
  6.     monitor.setTextColor(colors.white)
  7.     monitor.clear()
  8.     monitor.setTextScale(0.5)
  9.     monitor.setCursorPos(1, 1)
  10.     width, height = monitor.getSize()
  11. end
  12.  
  13. local function clean()
  14.     monitor.setBackgroundColor(colors.black)
  15.     monitor.setTextColor(colors.white)
  16.     monitor.setTextScale(0.5)
  17.     monitor.setCursorPos(1, 1)
  18. end
  19.  
  20. local function split(str, separator)
  21.     if separator == nil then
  22.         separator = "%s"
  23.     end
  24.     local t={}
  25.     for str in string.gmatch(str, "([^"..separator.."]+)") do
  26.         table.insert(t, str)
  27.     end
  28.     return t
  29. end
  30.  
  31. local function drawTitle()
  32.     local titleLength = string.len("MassaWish Inc")
  33.     local xPos = (width - titleLength) / 2
  34.     monitor.setCursorPos(1 + xPos, 2)
  35.     monitor.setBackgroundColor(colors.gray)
  36.     monitor.setTextColor(colors.purple)
  37.     monitor.write("MassaWish Inc")
  38.  
  39.     clean()
  40. end
  41.  
  42. local function drawDescription()
  43.     local description = {
  44.         "Accepted bets:",
  45.         " - Gold Ingot",
  46.         " - Diamond",
  47.         " - Small Coin",
  48.         " - Medium Coin",
  49.         "",
  50.         "Only 40% chance to LOSE!",
  51.         "",
  52.         "You WIN 6 out of 10 times!!",
  53.         "",
  54.         "Odds:",
  55.         "40% : Lose",
  56.         "20% : Small Win",
  57.         "15% : Item Back",
  58.         "15% : 2x Prize",
  59.         "8%  : 3x Prize",
  60.         "2%  : JACKPOT!"
  61.     }
  62.  
  63.     monitor.setCursorPos(1, 4)
  64.     for i = 1, #description do
  65.         local row = description[i] -- You WIN 6 out of 10 times!!
  66.         local words = split(row, " ")
  67.         local CursorX, CursorY
  68.         local xCount = 0
  69.         for j = 1, #words do
  70.             local word = words[j]
  71.             if j ~= 1 and ((xCount + #word) > width) then
  72.                 CursorX, CursorY = monitor.getCursorPos()
  73.                 monitor.setCursorPos(1, CursorY+1)
  74.                 xCount = 1
  75.             end
  76.             xCount = xCount + #word + 1
  77.             monitor.write(word .. " ")
  78.         end
  79.         CursorX, CursorY = monitor.getCursorPos()
  80.         monitor.setCursorPos(1, CursorY+1)
  81.     end
  82.  
  83.     clean()
  84. end
  85.  
  86. local function drawInstructions()
  87.     setup()
  88.     drawTitle()
  89.     drawDescription()
  90. end
  91.  
  92. while true do
  93.     drawInstructions()
  94.     sleep(15)
  95. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement