Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local monitor = peripheral.find("monitor")
- local slotPos = "bottom"
- local prizePos = "left"
- local bigPrizeCount = 10
- local prizeCount = 5
- function FixValue(val, color, color7)
- term.setTextColour(color)
- if (val == 0) then
- return "\7"
- elseif (val == 8) then
- term.setTextColour(color7)
- return 7
- end
- if (val == 1) then
- term.setTextColour(color7)
- return 7
- elseif (val == 2) then
- return "\2"
- elseif (val == 3) then
- return "\3"
- elseif (val == 4) then
- return "\4"
- elseif (val == 5) then
- return "\5"
- elseif (val == 6) then
- return "\6"
- elseif (val == 7) then
- return "\7"
- end
- end
- function Draw(a,b,c)
- term.clear()
- term.setTextColour(colors.yellow)
- term.setCursorPos(1,1)
- write("\127" .. "\127" .. "\127" .. "\127" .. "\127" .. "\127" .. "\127")
- for i=2,4 do
- term.setCursorPos(1,i)
- write("\127")
- term.setCursorPos(7,i)
- write("\127")
- end
- term.setTextColour(colors.lightGray)
- term.setCursorPos(2,2)
- write(FixValue(a-1, colors.lightGray, colors.gray))
- term.setCursorPos(4,2)
- write(FixValue(b-1, colors.lightGray, colors.gray))
- term.setCursorPos(6,2)
- write(FixValue(c-1, colors.lightGray, colors.gray))
- -- Actual values
- term.setTextColour(colors.white)
- term.setCursorPos(2,3)
- write(FixValue(a, colors.white, colors.red))
- term.setCursorPos(4,3)
- write(FixValue(b, colors.white, colors.red))
- term.setCursorPos(6,3)
- write(FixValue(c, colors.white, colors.red))
- term.setTextColour(colors.lightGray)
- term.setCursorPos(2,4)
- write(FixValue(a+1, colors.lightGray, colors.gray))
- term.setCursorPos(4,4)
- write(FixValue(b+1, colors.lightGray, colors.gray))
- term.setCursorPos(6,4)
- write(FixValue(c+1, colors.lightGray, colors.gray))
- term.setTextColour(colors.yellow)
- term.setCursorPos(1,5)
- write("\127" .. "\127" .. "\127" .. "\127" .. "\127" .. "\127" .. "\127")
- end
- function DispensePrize(qty)
- --TODO: Test
- for i=1,qty do
- rs.setAnalogOutput(prizePos, 1)
- sleep(0.2)
- rs.setAnalogOutput(prizePos, 0)
- sleep(0.2)
- end
- end
- function Game()
- local a = math.random(1,3)
- local b = math.random(1,3)
- local c = math.random(1,3)
- --Visual effect
- for i=1,35 do
- sleep(0.2)
- Draw(math.random(1,7),math.random(1,7),math.random(1,7))
- end
- Draw(a,b,c)
- --Big prize
- if (a == 1 and b == 1 and c == 1) then
- sleep(1)
- --term.clear()
- term.setTextColour(colors.green)
- term.setCursorPos(3,2)
- write("BIG")
- term.setCursorPos(1,3)
- write("WINNER!")
- DispensePrize(bigPrizeCount)
- return
- end
- -- Normal prize
- if (a == b and b == c) then
- sleep(1)
- --term.clear()
- term.setTextColour(colors.green)
- term.setCursorPos(1,3)
- write("WINNER!")
- DispensePrize(prizeCount)
- else
- sleep(1)
- --term.clear()
- term.setTextColour(colors.red)
- term.setCursorPos(3,2)
- write("TOO")
- term.setCursorPos(3,3)
- write("BAD")
- end
- end
- function ScreenSaver()
- Draw(math.random(1,3),math.random(1,3),math.random(1,3))
- end
- rs.setAnalogOutput(slotPos, 0)
- term.redirect(monitor)
- while(true) do
- sleep(1)
- ScreenSaver()
- os.pullEvent("redstone")
- rs.setAnalogOutput(slotPos, 15)
- Game()
- sleep(0.1)
- rs.setAnalogOutput(slotPos, 0)
- sleep(0.1)
- end
Advertisement
Add Comment
Please, Sign In to add comment