Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --setup / variables
- os.execute 'title Space Game'
- os.execute 'color 0b'
- os.execute 'cls'
- ship = {1 , "CLASS-1" , 2 , "CLASS-2"}
- shipname = ""
- capname = ""
- shiphull = 0
- money = 2000
- uranium = 0
- titanium = 0
- uranium_price = 150
- titanium_price = 500
- --------------------
- --pause func
- function pause()
- print ("\n{Press enter}")
- io.read()
- end
- function notop()
- print ("That's not an option. Try again.")
- pause()
- end
- function noteno()
- print ("You don't have enough to do that.")
- pause()
- end
- --------------------
- --shipname func
- while shipname == "" do
- print ("\n{Name your ship}:")
- shipname = io.read()
- if shipname == "" then
- notop()
- os.execute 'cls'
- else
- break
- end
- end
- while capname == "" do
- os.execute 'cls'
- print ("\n{Name your captain}:")
- capname = io.read()
- if capname == "" then
- notop()
- os.execute 'cls'
- else
- break
- end
- end
- --------------------
- function inventory()
- os.execute 'cls'
- print ("\n(You open up your ships inventory.)")
- print ("\n|INVENTORY|")
- print ("\n\n[URANIUM]: "..uranium.."")
- print ("[TITANIUM]: "..titanium.."")
- print ("\n[$CREDS$]: "..money.."")
- print ("\n\n{No options in inventory.}")
- pause()
- ss01()
- end
- --shop func
- function shop()
- os.execute 'cls'
- print ("\n(You are at Space Station "..ssname.."'s shop.)")
- print ("\n|SHOP|")
- print ("\n[$CREDS$]: "..money.."")
- print ("\n1. [BUY URANIUM]: "..uranium_price.."")
- print ("2. [SELL URANIUM]: "..uranium_price.."")
- print ("3. [BUY TITANIUM]: "..titanium_price.."")
- print ("4. [SELL TITANIUM]: "..titanium_price.."")
- print ("0. <--- Back")
- print ("\n{Select a number}:")
- shopop = io.read()
- if shopop == "1" and money >= uranium_price then
- money = money - uranium_price
- uranium = uranium + 1
- print ("You bought 1 Uranium. [ +1 Uranium ]")
- print ("Total Uranium: "..uranium.."")
- pause()
- shop()
- elseif shopop == "1" and money < uranium_price then
- noteno()
- shop()
- elseif shopop == "2" and uranium > 0 then
- money = money + uranium_price
- uranium = uranium - 1
- print ("You sold 1 Uranium. [ +$"..uranium_price.."")
- print ("Total Uranium: "..uranium.."")
- pause()
- shop()
- elseif shopop == "2" and uranium == 0 then
- noteno()
- shop()
- elseif shopop == "3" then
- money = money - titanium_price
- titanium = titanium + 1
- print ("You bought 1 Titanium. [ +1 Titanium ]")
- print ("Total Titanium: "..titanium.."")
- pause()
- shop()
- elseif shopop == "3" and money < titanium_price then
- noteno()
- shop()
- elseif shopop == "4" and titanium > 0 then
- money = money + titanium_price
- titanium = titanium - 1
- print ("You sold 1 Titanium. [ +$"..titanium_price.."")
- print ("Total Titanium: "..titanium.."")
- pause()
- shop()
- elseif shopop == "4" and titanium == 0 then
- noteno()
- shop()
- elseif shopop == "0" then
- ss01()
- else
- notop()
- shop()
- end
- end
- --------------------
- --job board func
- function joboard()
- end
- --------------------
- --repair func
- function repair()
- end
- --------------------
- --depart func
- function depart()
- end
- --------------------
- --space station 01
- function ss01()
- os.execute 'cls'
- ssname = "01"
- os.execute 'cls'
- print ("\n (You have started at Space Station "..ssname..")")
- print ("\n|#SPACE STATION#|"..ssname.."")
- print ("\n\n[VESSEL ID]: "..shipname.."")
- print ("[CPTN NAME]: "..capname.."")
- print ("[SHIP TYPE]: "..ship[2].."")
- print ("[$CREDS$]: "..money.."")
- print ("\n\n[USER COMMANDS]:")
- print ("\n{Type 'i' to open inventory}")
- print ("{Type 's' to open shop.}")
- print ("{Type 'j' to open job board.}")
- print ("{Type 'r' to repair ship hull.}")
- print ("{Type 'd' to depart from station.}")
- usercom = io.read()
- if usercom == "i" then
- inventory()
- elseif usercom == "s" then
- shop()
- elseif usercom == "j" then
- joboard()
- elseif usercom == "r" then
- repair()
- elseif usercom == "d" then
- depart()
- else
- notop()
- ss01()
- end
- end
- --------------------
- --Opening starting func
- ss01()
- --------------------
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement