SHARE
TWEET

Untitled

a guest Mar 25th, 2019 66 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. --setup / variables
  3. os.execute 'title Space Game'
  4. os.execute 'color 0b'
  5. os.execute 'cls'
  6. ship = {1 , "CLASS-1" , 2 , "CLASS-2"}
  7. shipname = ""
  8. capname = ""
  9. shiphull = 0
  10.  
  11. money = 2000
  12.  
  13. uranium = 0
  14. titanium = 0
  15.  
  16. uranium_price = 150
  17. titanium_price = 500
  18.  
  19. --------------------
  20.  
  21. --pause func
  22.  
  23. function pause()
  24.     print ("\n{Press enter}")
  25.     io.read()
  26. end
  27.  
  28. function notop()
  29.     print ("That's not an option. Try again.")
  30.     pause()
  31. end
  32.  
  33. function noteno()
  34.     print ("You don't have enough to do that.")
  35.     pause()
  36. end
  37.  
  38. --------------------
  39.  
  40. --shipname func
  41.  
  42. while shipname == "" do
  43.  
  44.     print ("\n{Name your ship}:")
  45.     shipname = io.read()
  46.  
  47.     if shipname == "" then
  48.         notop()
  49.         os.execute 'cls'
  50.     else
  51.         break
  52.     end
  53. end
  54.  
  55. while capname == "" do
  56.  
  57.     os.execute 'cls'
  58.  
  59.     print ("\n{Name your captain}:")
  60.     capname = io.read()
  61.  
  62.     if capname == "" then
  63.         notop()
  64.         os.execute 'cls'
  65.     else
  66.         break
  67.     end
  68. end
  69.  
  70. --------------------
  71.  
  72. function inventory()
  73.  
  74.     os.execute 'cls'
  75.  
  76.     print ("\n(You open up your ships inventory.)")
  77.  
  78.     print ("\n|INVENTORY|")
  79.  
  80.  
  81.     print ("\n\n[URANIUM]: "..uranium.."")
  82.     print ("[TITANIUM]: "..titanium.."")
  83.  
  84.     print ("\n[$CREDS$]: "..money.."")
  85.    
  86.     print ("\n\n{No options in inventory.}")
  87.     pause()
  88.     ss01()
  89. end
  90.  
  91. --shop func
  92.  
  93. function shop()
  94.  
  95.     os.execute 'cls'
  96.  
  97.     print ("\n(You are at Space Station "..ssname.."'s shop.)")
  98.  
  99.     print ("\n|SHOP|")
  100.  
  101.     print ("\n[$CREDS$]: "..money.."")
  102.  
  103.     print ("\n1. [BUY URANIUM]: "..uranium_price.."")
  104.     print ("2. [SELL URANIUM]: "..uranium_price.."")
  105.     print ("3. [BUY TITANIUM]: "..titanium_price.."")
  106.     print ("4. [SELL TITANIUM]: "..titanium_price.."")
  107.     print ("0. <--- Back")
  108.  
  109.     print ("\n{Select a number}:")
  110.  
  111.     shopop = io.read()
  112.  
  113.     if shopop == "1" and money >= uranium_price then
  114.         money = money - uranium_price
  115.         uranium = uranium + 1
  116.         print ("You bought 1 Uranium. [ +1 Uranium ]")
  117.         print ("Total Uranium: "..uranium.."")
  118.         pause()
  119.         shop()
  120.     elseif shopop == "1" and money < uranium_price then
  121.         noteno()
  122.         shop()
  123.     elseif shopop == "2" and uranium > 0 then
  124.         money = money + uranium_price
  125.         uranium = uranium - 1
  126.         print ("You sold 1 Uranium. [ +$"..uranium_price.."")
  127.         print ("Total Uranium: "..uranium.."")
  128.         pause()
  129.         shop()
  130.     elseif shopop == "2" and uranium == 0 then
  131.         noteno()
  132.         shop()
  133.     elseif shopop == "3" then
  134.         money = money - titanium_price
  135.         titanium = titanium + 1
  136.         print ("You bought 1 Titanium. [ +1 Titanium ]")
  137.         print ("Total Titanium: "..titanium.."")
  138.         pause()
  139.         shop()
  140.     elseif shopop == "3" and money < titanium_price then
  141.         noteno()
  142.         shop()
  143.     elseif shopop == "4" and titanium > 0 then
  144.         money = money + titanium_price
  145.         titanium = titanium - 1
  146.         print ("You sold 1 Titanium. [ +$"..titanium_price.."")
  147.         print ("Total Titanium: "..titanium.."")
  148.         pause()
  149.         shop()
  150.     elseif shopop == "4" and titanium == 0 then
  151.         noteno()
  152.         shop()
  153.     elseif shopop == "0" then
  154.         ss01()
  155.     else
  156.         notop()
  157.         shop()
  158.     end
  159. end
  160.  
  161. --------------------
  162.  
  163. --job board func
  164.  
  165. function joboard()
  166.  
  167. end
  168.  
  169. --------------------
  170.  
  171. --repair func
  172.  
  173. function repair()
  174.  
  175. end
  176.  
  177. --------------------
  178.  
  179. --depart func
  180.  
  181. function depart()
  182.  
  183. end
  184.  
  185. --------------------
  186.  
  187. --space station 01
  188.  
  189. function ss01()
  190.  
  191.     os.execute 'cls'
  192.  
  193.     ssname = "01"
  194.  
  195.     os.execute 'cls'
  196.  
  197.     print ("\n (You have started at Space Station "..ssname..")")
  198.  
  199.     print ("\n|#SPACE STATION#|"..ssname.."")
  200.  
  201.  
  202.     print ("\n\n[VESSEL ID]: "..shipname.."")
  203.     print ("[CPTN NAME]: "..capname.."")
  204.     print ("[SHIP TYPE]: "..ship[2].."")
  205.     print ("[$CREDS$]: "..money.."")
  206.  
  207.  
  208.     print ("\n\n[USER COMMANDS]:")
  209.  
  210.     print ("\n{Type 'i' to open inventory}")
  211.     print ("{Type 's' to open shop.}")
  212.     print ("{Type 'j' to open job board.}")
  213.     print ("{Type 'r' to repair ship hull.}")
  214.     print ("{Type 'd' to depart from station.}")
  215.  
  216.     usercom = io.read()
  217.    
  218.     if usercom == "i" then
  219.         inventory()
  220.     elseif usercom == "s" then
  221.         shop()
  222.     elseif usercom == "j" then
  223.         joboard()
  224.     elseif usercom == "r" then
  225.         repair()
  226.     elseif usercom == "d" then
  227.         depart()
  228.     else
  229.         notop()
  230.         ss01()
  231.     end
  232. end
  233.  
  234. --------------------
  235.  
  236. --Opening starting func
  237. ss01()
  238. --------------------
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top