Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --------------------------------------------
- -- to play this please use the installer
- -------------things to change------------------
- local limit = 10 --the minimum to play
- local perc = 0.15 --how much you earn each shot (100% = 1.00 and 1% = 0.01)
- ------------------------------
- local amount = limit
- local earn = 0
- local death = false
- local earned = 0
- local ongoing = true
- local enter = true
- -----------------------------------
- one = true
- two = true
- three = true
- four = true
- five = true
- six = true
- function readCard()
- if not fs.exists("disk/creds.lua") then
- os.reboot()
- end
- local Card = fs.open("disk/creds.lua", "r")
- data = Card.readAll()
- Card.close()
- a, b = string.find(data, "11066011")
- c, d = string.find(data, "11077011")
- creds = tonumber(string.sub(data, b+1, c-1))
- if creds < limit then
- paintutils.drawFilledBox(1, 1, 51, 19, colors.green)
- term.clear()
- term.setCursorPos(5, 10)
- term.write("{you don't have enough credits to continiue}")
- while fs.exists("disk/") do
- sleep(0,5)
- end
- os.reboot()
- end
- end
- function writeCard()
- if not fs.exists("disk/creds.lua") then
- os.reboot()
- end
- local Card = fs.open("disk/creds.lua", "w")
- data = (tostring(math.random(1, 163456)).."11066011"..tostring(creds).."11077011"..tostring(math.random(1, 163456)))
- Card.write(tostring(data))
- Card.close()
- disk.setLabel("bottom", tostring(creds).."$")
- end
- local chamber = paintutils.loadImage("images/chamber.nfp")
- local revolver = paintutils.loadImage("images/revolver.nfp")
- function insert_card()
- paintutils.drawFilledBox(1, 1, 51, 19, colors.black)
- paintutils.drawImage(revolver, 14, 2)
- while not fs.exists("disk/") do
- term.clear()
- paintutils.drawFilledBox(1, 1, 51, 19, colors.black)
- paintutils.drawImage(revolver, 14, 2)
- term.setCursorPos(16, 10)
- term.setBackgroundColor(colors.black)
- term.write("{please insert card}")
- sleep(1)
- end
- term.clear()
- end
- function insert_amount()
- amount = limit
- paintutils.drawFilledBox(1, 1, 51, 19, colors.black)
- enter = true
- while enter do
- if not fs.exists("disk/creds.lua") then
- os.reboot()
- end
- term.clear()
- term.setCursorPos(18, 6)
- term.write("{bidding amount}")
- term.setCursorPos(2, 7)
- term.write("every shot you take you earn "..(perc * 100).."% of your amount")
- term.setCursorPos(24, 10)
- term.write("|"..amount.."$|")
- local event, key, is_held = os.pullEvent("key")
- while key==keys.up and amount < creds do
- amount = amount+1
- term.setCursorPos(24, 10)
- term.clear()
- term.write("|"..amount.."$|")
- term.setCursorPos(18, 6)
- term.write("{bidding amount}")
- term.setCursorPos(2, 7)
- term.write("every shot you take you earn "..(perc * 100).."% of your amount")
- key = nil
- local event, key, is_held = os.pullEvent("key")
- end
- while key==keys.down and amount>limit do
- amount = amount-1
- term.setCursorPos(24, 10)
- term.clear()
- term.write("|"..amount.."$|")
- term.setCursorPos(18, 6)
- term.write("{bidding amount}")
- term.setCursorPos(2, 7)
- term.write("every shot you take you earn "..(perc * 100).."% of your amount")
- key = nil
- local event, key, is_held = os.pullEvent("key")
- end
- key = nil
- local event, key, is_held = os.pullEvent("key")
- if key==keys.enter then
- enter = false
- end
- end
- creds = creds - amount
- writeCard()
- if not fs.exists("disk/creds.lua") then
- os.reboot()
- end
- earn = amount * perc
- end
- function died()
- paintutils.drawFilledBox(1, 1, 51, 19, colors.white)
- sleep(1)
- term.setCursorPos(22, 9)
- term.blit("You died", "77777777", "00000000")
- sleep(3)
- end
- function game()
- paintutils.drawFilledBox(1, 1, 51, 19, colors.black)
- term.clear()
- term.setCursorPos(40, 8)
- term.setTextColor(1)
- term.write(earned.."$ earned")
- local bullet = math.random(6)
- paintutils.drawImage(chamber, 5, 4)
- ongoing = true
- local event, kb, x, y = os.pullEvent()
- while ongoing == true do
- local event, kb, x, y = os.pullEvent()
- if event == "mouse_click" then
- term.setCursorPos(20, 1)
- if (24 <= x) and (x <= 26) and (5 <= y) and (y <= 6) and (one == true) then --1
- if bullet == 1 then
- ongoing = false
- death = true
- died()
- else
- earned = earned + earn
- one = false
- term.blit("1 is empty", "1111111111", "ffffffffff")
- paintutils.drawFilledBox(24, 5, 26, 6, colors.black)
- end
- elseif (30 <= x) and (x <= 32) and (8 <= y) and (y <= 9) and (two == true) then --2
- if bullet == 2 then
- ongoing = false
- death = true
- died()
- else
- earned = earned + earn
- two = false
- term.blit("2 is empty", "1111111111", "ffffffffff")
- paintutils.drawFilledBox(30, 8, 32, 9, colors.black)
- end
- elseif (30 <= x) and (x <= 32) and (12 <= y) and (y <= 13) and (three == true) then --3
- if bullet == 3 then
- ongoing = false
- death = true
- died()
- else
- earned = earned + earn
- three = false
- term.blit("3 is empty", "1111111111", "ffffffffff")
- paintutils.drawFilledBox(30, 12, 32, 13, colors.black)
- end
- elseif (24 <= x) and (x <= 26) and (15 <= y) and (y <= 16) and (four == true) then --4
- if bullet == 4 then
- ongoing = false
- death = true
- died()
- else
- earned = earned + earn
- four = false
- term.blit("4 is empty", "1111111111", "ffffffffff")
- paintutils.drawFilledBox(24, 15, 26, 16, colors.black)
- end
- elseif (18 <= x) and (x <= 20) and (12 <= y) and (y <= 13) and (five == true) then --5
- if bullet == 5 then
- ongoing = false
- death = true
- died()
- else
- earned = earned + earn
- five = false
- term.blit("5 is empty", "1111111111", "ffffffffff")
- paintutils.drawFilledBox(18, 12, 20, 13, colors.black)
- end
- elseif (18 <= x) and (x <= 20) and (8 <= y) and (y <= 9) and (six == true) then --6
- if bullet == 6 then
- ongoing = false
- death = true
- died()
- else
- earned = earned + earn
- six = false
- term.blit("6 is empty", "1111111111", "ffffffffff")
- paintutils.drawFilledBox(18, 8, 20, 9, colors.black)
- end
- end
- term.setCursorPos(40, 8)
- term.write(earned.."$ earned")
- elseif kb == keys.enter then
- term.setCursorPos(15, 1)
- term.blit("you spun the chamber", "11111111111111111111", "ffffffffffffffffffff")
- sleep(1)
- one = true
- two = true
- three = true
- four = true
- five = true
- six = true
- ongoing = false
- end
- end
- end
- while 1 do
- earned = 0
- insert_card()
- readCard()
- insert_amount()
- writeCard()
- death = false
- one = true
- two = true
- three = true
- four = true
- five = true
- six = true
- while death == false do
- game()
- end
- readCard()
- creds = creds + earned
- writeCard()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement