Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local Losses = 1
- local Jackpot = 0
- local Charge = 5
- local Jackpot_Growth = {0,2}--{mode,number}, mode 0=X Loss, 1 = add each roll, 2 = static, 3 = random per loss
- local Display_Mode = 0--0=Computer,1=Monitor
- local Currency = {{"create_deco:brass_coin",64},{"createdeco:iron_coin",16},{"createdeco:copper_coin",1}}
- local Payment_Box
- local Store_Box
- local Jackpot_Box
- local Chance_Sheet
- local Win_Sheet
- local Roll_Sheet
- local Monitor
- function Dispense(amount)
- local E = 0
- for i = 1, Store_Box.size() do
- local Slot = Store_Box.getItemDetail(i)
- if E > 0 and Slot ~= nil then local A = Slot.count Store_Box.pushItems(peripheral.getName(Payment_Box),i,E) if E - A < 0 then E = 0 else E = E - A end end
- end
- end
- function Jackpot_Dispense()
- for i = 1, Jackpot_Box.size() do
- Jackpot_Box.pushItems(peripheral.getName(Payment_Box),i)
- end
- end
- function Requirements()
- local Check = false
- local E = 0
- for i = 1, Payment_Box.size() do
- local Slot = Payment_Box.getItemDetail(i)
- for M = 1, #Currency do
- if Currency[M][1] == Slot.name then E = E + Currency[M][2] * Slot.count Payment_Box.pushItems(peripheral.getName(Jackpot_Box),i) end
- end
- end
- if E == Charge then Check = true end
- return Check
- end
- function UpdateData()
- local Data = {Losses, Jackpot, Charge, Display_Mode, Jackpot_Growth}
- local file = fs.open("settings.txt","w")
- file.write(textutils.serialize(Data))
- file.close()
- end
- function Boot()
- local file = fs.open("settings.txt","r")
- local Data = textutils.unserialize(file.readAll())
- Losses, Jackpot, Charge, Display_Mode, Jackpot_Growth = Data[1], Data[2], Data[3], Data[4], Data[5]
- file.close()
- if Display_Mode == 0 then Monitor = term else Monitor = peripheral.wrap("top") end
- if Jackpot_Growth[1] == 2 then Jackpot = Jackpot_Growth[2] end
- Start()
- end
- function Display_Menu()
- Monitor.clear()
- Monitor.setCursorPos(1,1)
- Monitor.write("JACKPOT:")
- Monitor.setCursorPos(1,2)
- Monitor.write("$"..Jackpot)
- Monitor.setCursorPos(1,3)
- Monitor.write("insert")
- Monitor.setCursorPos(1,4)
- Monitor.write("$"..Charge)
- end
- function Display_Game(roll)
- roll = tostring(roll)
- local a, b, c = string.sub(roll,1,1), string.sub(roll,2,2), string.sub(roll,3,3)
- Monitor.clear()
- Monitor.setCursorPos(1,1)
- Monitor.write("SPIN!")
- Monitor.setCursorPos(3,2)
- Monitor.write("===========")
- Monitor.setCursorPos(1,5)
- Monitor.write("===========")
- Monitor.setCursorPos(3,4)
- Monitor.write("["..a.."]|["..b.."]|["..c.."]")
- Monitor.setCursorPos(1,6)
- Monitor.write("Combos")
- local file = fs.open(Win_Sheet,"r")
- local Data = textutils.unserialize(file.readAll())
- file.close()
- for i = 1, #Data do
- Monitor.setCursorPos(1,i+6)
- Monitor.write(Data[i][1].." : $"..Data[i][2])
- end
- end
- function Display_WIN(title,amount)
- Monitor.clear()
- Monitor.setCursorPos(4,6)
- Monitor.write(title)
- Monitor.setCursorPos(4,7)
- Monitor.write("$"..amount)
- end
- function Spin()
- local Result = 0--0=loss,1=win,2=jackpot
- local file = fs.open(Chance_Sheet,"r")
- local Data = textutils.unserialize(file.readAll())
- file.close()
- local Roll = math.random(1,100)
- if Roll == Data[Losses] then Result = 2 elseif Roll>Data[Losses]-8 and Roll<Data[Losses]+8 then Result = 1 end
- local Rolls = fs.open(Roll_Sheet,"r")
- local R = textutils.unserialize(Rolls.readAll())
- Rolls.close()
- for i = math.random(1,5), 8 do
- Display_Game(R[i])
- os.sleep(2)
- end
- if Result == 2 then
- Display_Game("777")
- Losses = 1
- os.sleep(2)
- Display_WIN("JACKPOT! 777",Jackpot)
- Jackpot_Dispense()
- os.sleep(3)
- Jackpot = 0
- elseif Result == 1 then
- local Ws = fs.open(Win_Sheet,"r")
- local RW = textutils.unserialize(Ws.readAll())
- Ws.close()
- local WinData = RW[math.random(1,#RW)]
- Display_Game(WinData[1])
- Losses = 1
- os.sleep(2)
- Display_WIN("Congratulations!",WinData[2])
- Dispense(WinData[2])
- os.sleep(3)
- elseif Result == 0 then
- if Jackpot_Growth[1] == 3 and math.random(1,Jackpot_Growth[2]) == 1 then
- Jackpot = Jackpot + Charge
- elseif Jackpot_Growth[1] == 0 then
- Jackpot = Jackpot_Growth[2] * Losses
- end
- Losses = Losses + 1
- end
- if Jackpot_Growth[1] == 1 then
- Jackpot = Jackpot + Jackpot_Growth[2]
- end
- end
- function Start()
- while true do
- Display_Menu()
- local a, b, c, d, e = os.pullEvent("redstone")
- if Requirements() == true then Spin() end
- UpdateData()
- end
- end
- Boot()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement