SteamPunk_Devil

SteAmPI ReWrite

Mar 8th, 2014
271
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 5.77 KB | None | 0 0
  1. --steAmPI By SteamPunk_Devil IGN - SteamPunk_Angel--
  2. --Feel free to edit this in anyway as long as you credit me(and tell me if you can)--
  3. --Initials: SPD = SteamPunk_Devil,
  4.  
  5. print("Successfully Loaded steAmPI, Version: Beta V1.0, By: SPD, Release Date: 08/03/2014") --Change release date and version every full release, The "By" is the initials of whoever release it and full names can be found in the header
  6.  
  7. function version() --Displays version
  8.         print("Beta V1.0, By SPD, Release Date: 08/03/2014") --Same as above
  9. end
  10.  
  11. function Percentage(current,total) --returns One number as a percentage of the second one --TBD Round to a Decimal place
  12.  
  13.         local No1 = current
  14.         local No2 = total
  15.         local Percent = (current / total) * 100
  16.  
  17.         return Percent
  18. end
  19.  
  20. function Buckets(miliBuckets) -- turns milibuckets to buckets
  21.         local total = miliBuckets / 1000
  22.         return total
  23. end
  24.  
  25. function Round(num, idp)
  26.   local mult = 10^(idp or 0)
  27.   return math.floor(num * mult + 0.5) / mult
  28. end
  29.  
  30. function PercentBar(CursorX, CursorY, InActiveColor, ActiveColor, TextColor, n, Mon)
  31.         local n10 = n/10
  32.         local FormdN =  Round(n10, 0)
  33.         local BarCursX = CursorX
  34.         local BarCursY = CursorY
  35.         local Paste = Mon
  36.         Paste.setCursorPos(CursorX, CursorY)  
  37.         Paste.setBackgroundColor(InActiveColor)
  38.         Paste.write("          ")
  39.         Paste.setCursorPos(CursorX, CursorY)
  40.         Paste.setBackgroundColor(ActiveColor)
  41.         Paste.setTextColor(TextColor)
  42.         Paste.write(string.rep("/", FormdN))
  43.         BarCursX = BarCursX + 10
  44.         Paste.setBackgroundColor(32768)
  45.         Paste.setTextColor(1)
  46. end
  47.  
  48. function FluNamePicker(FluName)
  49.         if FluName == "bioethanol" then
  50.                 TankSpecs = {}
  51.                 TankSpecs["Name"] = "Ethanol"
  52.                 TankSpecs["BarColor"] = 2
  53.                 TankSpecs["TextColor"] = 16
  54.                 return TankSpecs
  55.         elseif FluName == "steam" then
  56.                 TankSpecs = {}
  57.                 TankSpecs["Name"] = "Steam"
  58.                 TankSpecs["BarColor"] = 256
  59.                 TankSpecs["TextColor"] = 1
  60.                 return TankSpecs
  61.         elseif FluName == "xpjuice" then
  62.                 TankSpecs = {}
  63.                 TankSpecs["Name"] = "XP"
  64.                 TankSpecs["BarColor"] = 32
  65.                 TankSpecs["TextColor"] = 8192
  66.                 return TankSpecs
  67.         elseif FluName == "creosote" then
  68.                 TankSpecs = {}
  69.                 TankSpecs["Name"] = "Creo Oil"
  70.                 TankSpecs["BarColor"] = 4096
  71.                 TankSpecs["TextColor"] = 2
  72.                 return TankSpecs
  73.         elseif FluName == "honey" then
  74.                 TankSpecs = {}
  75.                 TankSpecs["Name"] = "Honey"
  76.                 TankSpecs["BarColor"] = 16
  77.                 TankSpecs["TextColor"] = 4096
  78.                 return TankSpecs
  79.         elseif FluName == "seedoil" then
  80.                 TankSpecs = {}
  81.                 TankSpecs["Name"] = "Seed Oil"
  82.                 TankSpecs["BarColor"] = 16
  83.                 TankSpecs["TextColor"] = 8192
  84.                 return TankSpecs
  85.         elseif FluName == "liquiddna" then
  86.                 TankSpecs = {}
  87.                 TankSpecs["Name"] = "Liquid DNA"
  88.                 TankSpecs["BarColor"] = 1024
  89.                 TankSpecs["TextColor"] = 8
  90.                 return TankSpecs
  91.         else
  92.                 TankSpecs = {}
  93.                 TankSpecs["Name"] = FluName
  94.                 TankSpecs["BarColor"] = 1
  95.                 TankSpecs["TextColor"] = 512
  96.                 return TankSpecs
  97.         end
  98. end
  99.  
  100. function FluPrinter(FluDetails, Mon, Pos)
  101.         local x = 1
  102.         local y = 1
  103.     if Pos == 1 then
  104.         x = 2
  105.         y = 2
  106.     elseif Pos == 2 then
  107.         x = 18
  108.         y = 2
  109.     elseif Pos == 3 then
  110.         x = 2
  111.         y = 5
  112.     elseif Pos == 4 then
  113.         x = 18
  114.         y = 5
  115.     elseif Pos == 5 then
  116.         x = 2
  117.         y = 8
  118.     elseif Pos == 6 then
  119.         x = 18
  120.         y = 8
  121.     elseif Pos == 7 then
  122.         x = 2
  123.         y = 11
  124.     elseif Pos == 8 then
  125.         x = 18
  126.         y = 11
  127.     else
  128.     end
  129.        
  130. local TankName = FluDetails
  131. local Tank = peripheral.wrap(TankName)
  132. local TankDetails = Tank.getTankInfo("unknown")
  133. local name = TankDetails["name"]
  134. local TankSpecs = FluNamePicker(name)
  135. local FormdName = TankSpecs["Name"]
  136. local ActiveColor = TankSpecs["BarColor"]
  137. local TextColor = TankSpecs["TextColor"]
  138.     Mon.setCursorPos(x, y)
  139.     Mon.setTextColor(colors.white)
  140.     Mon.write(FormdName)
  141.     local Percent = Percentage(Amount,Cap)
  142.     PercentBar(x, y + 1, 128, ActiveColor, TextColor, Percent, Mon)
  143. end
  144.  
  145. function OnPushData(FluDetails, Mon)
  146.         local Tank = peripheral.wrap(FLuDetails)
  147.         local TankData = Tank.getTankInfo("unknown")
  148.         local FluNameT = FluNamePicker(TankData["name"])
  149.         local Amount = FluDetails["amount"]
  150.         local Cap = FluDetails["capacity"]
  151.         local Percent = Percentage(Amount, Cap)
  152.         local RPercent = Round(Percent, 2)
  153.         local FluName = FluNameT["Name"]
  154.         Mon.clear()
  155.         Mon.setCursorPos(5,2)
  156.         Mon.setTextScale(2)
  157.         Mon.setTextColor(colors.white)
  158.         Mon.write(FluName)
  159.         Mon.setTextScale(1)
  160.         Mon.setCursorPos(3,3)
  161.         Mon.write("" .. Amount .. "/" .. Cap .. "")
  162.         Mon.setCursorPos(3,4)
  163.         Mon.write("" .. RPercent .. "%")
  164.         Mon.setCursorPos(13,10)
  165.         Mon.setBackgroundColor(colors.red)
  166.         Mon.setTextColor(colors.black)
  167.         Mon.write("<Back")
  168.         Mon.setBackgroundColor(colors.black)
  169.        while true do
  170.   event, side, xPos, yPos = os.pullEvent("monitor_touch")
  171.   --print(event .. " => Side: " .. tostring(side) .. ", " ..
  172.     --"X: " .. tostring(xPos) .. ", " ..
  173.     --"Y: " .. tostring(yPos))
  174.   if yPos == 10 and xPos >= 13 and xPos <= 17 then
  175.     return -- end the function
  176.   end
  177. end
  178. end
Advertisement
Add Comment
Please, Sign In to add comment