Savage_Me55iah

CC_API_generalinfo

Jul 19th, 2017
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 6.38 KB | None | 0 0
  1. --Script by Savage_Me55iah of CraftAU.com.au--
  2.  
  3. --Other Savage_Me55iah scripts @ http://pastebin.com/u/Savage_Me55iah
  4.  
  5. --INSTRUCTIONS ON USE--
  6. --Instruction video on http://youtube.com/savagemessiah5
  7.  
  8. --Contact Savage_Me55iah @ CraftAU.com.au or http://www.computercraft.info/forums2/ with suggestions/fixes/bugs
  9.  
  10. local scriptName = "generalinfo"
  11. fileDetail = fileDetail or {}
  12. fileDetail[scriptName] = {["version"] = 0.1, ["pastebin"] = "4a8jhYMe"}
  13.  
  14. local tArgs = {...}
  15. if tArgs[1] == "update" then
  16.     print("UPDATING") shell.run("pastebin get "..fileDetail[scriptName].pastebin.." "..scriptName.."_update")
  17.     if fs.exists(scriptName.."_update") then fs.remove(shell.getRunningProgram()) fs.copy(scriptName.."_update", shell.getRunningProgram()) fs.remove(scriptName.."_update") print("UPDATE SUCCESS") else print("UPDATE FAILED") end
  18. end
  19.  
  20. -----------------------------------------------------------------------------------------------------------
  21. -- Variables --
  22. -----------------------------------------------------------------------------------------------------------
  23.  
  24. generalInfo = {}
  25.  
  26. generalInfo["colors"] = {
  27.     ["white"] = {["color"] = colors.white, ["decimal"] = 1, ["hexadecimal"] = "0x1", ["binary"] = 0000000000000001, ["paint"] = 0, ["display"] = "#F0F0F0"},
  28.     ["orange"] = {["color"] = colors.orange, ["decimal"] = 2, ["hexadecimal"] = "0x2", ["binary"] = 0000000000000010, ["paint"] = 0, ["display"] = "#F2B233"},
  29.     ["magenta"] = {["color"] = colors.magenta, ["decimal"] = 4, ["hexadecimal"] = "0x4", ["binary"] = 0000000000000100, ["paint"] = 0, ["display"] = "#E57FD8"},
  30.     ["lightBlue"] = {["color"] = colors.lightBlue, ["decimal"] = 8, ["hexadecimal"] = "0x8", ["binary"] = 0000000000001000, ["paint"] = 0, ["display"] = "#99B2F2"},
  31.     ["yellow"] = {["color"] = colors.yellow, ["decimal"] = 16, ["hexadecimal"] = "0x10", ["binary"] = 0000000000010000, ["paint"] = 0, ["display"] = "#DEDE6C"},
  32.     ["lime"] = {["color"] = colors.lime, ["decimal"] = 32, ["hexadecimal"] = "0x20", ["binary"] = 0000000000100000, ["paint"] = 0, ["display"] = "#7FCC19"},
  33.     ["pink"] = {["color"] = colors.pink, ["decimal"] = 64, ["hexadecimal"] = "0x40", ["binary"] = 0000000001000000, ["paint"] = 0, ["display"] = "#F2B2CC"},
  34.     ["gray"] = {["color"] = colors.gray, ["decimal"] = 128, ["hexadecimal"] = "0x80", ["binary"] = 0000000010000000, ["paint"] = 0, ["display"] = "#4C4C4C"},
  35.     ["lightGray"] = {["color"] = colors.lightGray, ["decimal"] = 256, ["hexadecimal"] = "0x100", ["binary"] = 0000000100000000, ["paint"] = 0, ["display"] = "#999999"},
  36.     ["cyan"] = {["color"] = colors.cyan, ["decimal"] = 512, ["hexadecimal"] = "0x200", ["binary"] = 0000001000000000, ["paint"] = 0, ["display"] = "#4C99B2"},
  37.     ["purple"] = {["color"] = colors.purple, ["decimal"] = 1024, ["hexadecimal"] = "0x400", ["binary"] = 0000010000000000, ["paint"] = 0, ["display"] = "#B266E5"},
  38.     ["blue"] = {["color"] = colors.blue, ["decimal"] = 2048, ["hexadecimal"] = "0x800", ["binary"] = 0000100000000000, ["paint"] = 0, ["display"] = "#3366CC"},
  39.     ["brown"] = {["color"] = colors.brown, ["decimal"] = 4096, ["hexadecimal"] = "0x1000", ["binary"] = 0001000000000000, ["paint"] = 0, ["display"] = "#7F664C"},
  40.     ["green"] = {["color"] = colors.green, ["decimal"] = 8192, ["hexadecimal"] = "0x2000", ["binary"] = 0010000000000000, ["paint"] = 0, ["display"] = "#57A64E"},
  41.     ["red"] = {["color"] = colors.red, ["decimal"] = 16384, ["hexadecimal"] = "0x4000", ["binary"] = 0100000000000000, ["paint"] = 0, ["display"] = "#CC4C4C"},
  42.     ["black"] = {["color"] = colors.black, ["decimal"] = 32768, ["hexadecimal"] = "0x8000", ["binary"] = 1000000000000000, ["paint"] = 0, ["display"] = "#191919"}
  43. }
  44.  
  45. generalInfo["sides"] = {
  46.     ["turtle"] = {"top", "bottom", "front", "right", "back", "left"},
  47.     ["computer"] = {"up", "down", "front", "right", "back", "left"}
  48. }
  49.  
  50. generalInfo["sidesReverse"] = {
  51.     ["turtle"] = {["bottom"] = "top", ["top"] = "bottom", ["left"] = "right", ["right"] = "left", ["front"] = "back", ["back"] = "front"},
  52.     ["computer"] = {["down"] = "up", ["up"] = "down", ["left"] = "right", ["right"] = "left", ["front"] = "back", ["back"] = "front"}
  53. }
  54. generalInfo["directions"] = {"up", "down", "north", "east", "south", "west"}
  55. generalInfo["directionsReverse"] = {["down"] = "up", ["up"] = "down", ["north"] = "south", ["south"] = "north", ["east"] = "west", ["west"] = "east"}
  56. generalInfo["cardinalDirections"] = {"north", "east", "south", "west"}
  57.  
  58. -----------------------------------------------------------------------------------------------------------
  59. -- API Functions --
  60. -----------------------------------------------------------------------------------------------------------
  61.  
  62.  
  63. -- generalinfo.chestDirTranslator(functionNum) -- [1] returns true if function ran correctly OR if false variable was nil
  64. -- main function. assign, records and displays logged text, use separate program to overview the log table
  65. function chestDirTranslator(param_functionNum)
  66.     local result, functionNum, sides, directions = {false}, param_functionNum.."/002", {"front", "right", "back", "left"}, {"north", "east", "south", "west"}
  67.     generalInfo["chestDirTranslator"] = {["up"] = "up", ["down"] = "down", ["top"] = "up", ["bottom"] = "down"}
  68.     if tostring(facing) ~= "nil" then
  69.         for a,b in pairs(directions) do
  70.             if b == facing then
  71.                 e = a
  72.                 for c,d in pairs(sides) do
  73.                     result[1], generalInfo["chestDirTranslator"][d] = true, directions[e]
  74.                     e = e + 1
  75.                     if e > 4 then e = 1 end
  76.         end end end
  77.     else
  78.         logger.logger(functionNum, {"Missing >facing< variable error eg (facing = north)"}, 1, " ")
  79.     end
  80.     return result
  81. end
  82.  
  83. -- generalinfo.stringAdjuster(functionNum) -- [1] returns true if function ran correctly OR if false variable was nil
  84. -- main function. assign, records and displays logged text, use separate program to overview the log table
  85. function stringAdjuster(param_functionNum, param_name)
  86.     local result, functionNum = {false, false}, param_functionNum.."/002"
  87.     if param_name == "east" or param_name == "west" or param_name == "down" then
  88.         result = {true, param_name.." "}
  89.     elseif param_name == "up" then
  90.         result = {true, param_name.."   "}
  91.     elseif param_name == "left" or param_name == "back" then
  92.         result = {true, param_name.."  "}
  93.     elseif param_name == "right" or param_name == "front" then
  94.         result = {true, param_name.." "}
  95.     elseif param_name == "top" then
  96.         result = {true, param_name.."   "}
  97.     else
  98.         result = {true, param_name}
  99.     end
  100.     return result
  101. end
Advertisement
Add Comment
Please, Sign In to add comment