Advertisement
Nothy

Economy

May 13th, 2016
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.48 KB | None | 0 0
  1. local tArgs = {...}
  2. local totalEconomy = tArgs[1]
  3. local expenses = 0
  4. print("Calculating your economy..")
  5. for k,v in ipairs(tArgs) do
  6.   if k >= 2 then
  7.     expenses = expenses + v
  8.  
  9.   end
  10.   if k == 1 and v == "update" then
  11.     data = http.get("https://www.dropbox.com/s/0hhlsnfr7lmdv1v/economy?dl=1")
  12.     file = fs.open(shell.getRunningProgram(),"w")
  13.     file.write(data.readAll())
  14.     file.close()
  15.     data.close()
  16.     print("Updated Economy!")
  17.     print("Rebooting.")
  18.     startupData = fs.open("startup","w")
  19.     newData = [[
  20.     print("Economy was updated successfully.")
  21.     print("You can now use it with the following command:")
  22.     print("economy <total income> <expense> <expense> <exense> . . .")
  23.     fs.delete("startup")
  24.     ]]
  25.     startupData.write(newData)
  26.     startupData.close()
  27.     os.reboot()
  28.   end
  29. end
  30. sleep(0.5)
  31. local profit = (tonumber(totalEconomy) - expenses)
  32. print("Expenses: "..expenses)
  33. print("Income:"..totalEconomy)
  34. if profit > 500 then
  35.   term.setTextColor(colors.green)
  36.   print("Budget:"..profit)
  37. else
  38.  term.setTextColor(colors.red)
  39.  print("Budget:"..profit)
  40. end
  41. term.setTextColor(colors.white)
  42. if profit >= 1000 or tonumber(totalEconomy) >=  expenses then
  43.   print("Economy is in good standing!")
  44. else
  45.   print("Problems:")
  46.  
  47.   if profit <= 1000 then
  48.     print("- Budget is dangerously low.")
  49.   end
  50.   if tonumber(totalEconomy) < expenses then
  51.     print("- Expenses are larger than your income!")
  52.   end
  53.   --print("Economy needs work.")
  54. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement