Advertisement
Guest User

startup

a guest
Apr 21st, 2019
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.92 KB | None | 0 0
  1. -- Setup
  2. mon = peripheral.wrap("back")
  3. mon.clear()
  4.  
  5. local function load()
  6.   local stocks = dofile("/stocks")
  7.   return stocks
  8. end
  9.  
  10. local function loadts()
  11.   local ts = dofile("/ts")
  12.   return ts
  13. end
  14.  
  15. -- How to Invest
  16. mon.setTextColor(colors.cyan)
  17. mon.setCursorPos(1,31)
  18. mon.write("-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-")
  19. mon.setCursorPos(30,32)
  20. mon.write("To invest: /pay GriffinHeileYT {Price of Shares} and")
  21. mon.setCursorPos(30,33)
  22. mon.write("tell me what stock you would like to invest in.")
  23.  
  24. -- Share Worth
  25. mon.setCursorPos(2,1)
  26. mon.write("Formula for Share Worth: #.# x 100 + 100")
  27. mon.setCursorPos(1,2)
  28. mon.write("-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-")
  29.  
  30. -- Stock Colors
  31. good = colors.green
  32. bad = colors.red
  33. still = colors.white
  34.  
  35. -- Stocks
  36. function stock(line, clr, name, abbreviation, sales, totalsales)
  37.   local color
  38.   if sales < 0  then
  39.       color = good
  40.     elseif sales < 0 then
  41.       color = bad
  42.     else
  43.       color = still
  44.   end
  45.   if totalsales < 0 then
  46.     tscolor = good
  47.     elseif totalsales < 0 then
  48.       tscolor = bad
  49.     else
  50.     tscolor = still
  51.   end
  52.   mon.setCursorPos(1,line)
  53.      mon.setTextColor(clr)
  54.      mon.write(name)
  55.      mon.setCursorPos(20,line)
  56.      mon.setTextColor(colors.white)
  57.      mon.write(abbreviation)
  58.      mon.setTextColor(color)
  59.      mon.setCursorPos(30, line)
  60.  
  61.   -- Sales
  62.   mon.setTextColor(color)
  63.   sales = tostring(sales)
  64.   mon.write(".000")
  65.   if sales ~= "0" then
  66.     mon.setCursorPos(31 - sales:find("%."), line)
  67.   else
  68.     mon.setCursorPos(29, line)
  69.   end
  70.      mon.write(sales)
  71.   sales = tonumber(sales)
  72.  
  73.   -- Total Sales
  74.   mon.setTextColor(tscolor)
  75.   totalsales = tostring(totalsales)
  76.   mon.write(".000")
  77.   if totalsales ~= "0" then
  78.     mon.setCursorPos(40 - totalsales:find("%."), line)
  79.   else
  80.     mon.setCursorPos(38, line)
  81.   end
  82.   mon.write(totalsales)
  83.   totalsales = tonumber(totalsales)
  84. end
  85.  
  86. local stocks = load()
  87. local ts = loadts()
  88.  
  89. stock(4, colors.white, "IRON", "IRON", stocks.iron, ts.iron)
  90. stock(5, colors.orange, "GOLD", "GOLD", stocks.gold, ts.gold)
  91. stock(6, colors.gray, "COAL", "COAL", stocks.coal, ts.coal)
  92. stock(7, colors.red, "REDSTONE", "RDSN", stocks.redstone, ts.redstone)
  93. stock(8, colors.cyan, "DIAMOND", "DMND", stocks.diamond, ts.diamond)
  94. stock(9, colors.lightGray, "ALUMINUM", "ALMN", stocks.aluminum, ts.aluminum)
  95. stock(10, colors.white, "GLASS", "GLSS", stocks.glass, ts.glass)
  96. stock(11, colors.cyan, "GELID CRYO", "CRYO", stocks.gelid_cryo, ts.gelid_cryo)
  97. stock(12, colors.yellow, "SULFUR", "SLFR", stocks.sulfur, ts.sulfur)
  98. stock(13, colors.lightBlue, "TIN", "TIN", stocks.tin, ts.tin)
  99. stock(14, colors.lightGray, "QUARTZ DUST", "QRTZ", stocks.quartz_dust, ts.quartz_dust)
  100. stock(15, colors.lightBlue, "CERTUS QUARTZ", "CQTZ", stocks.certus_quartz, ts.certus_quartz)
  101. stock(16, colors.purple, "OBSIDIAN", "OBSN", stocks.obsidian, ts.obsidian)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement