Advertisement
willwac

Flesh API

Jul 3rd, 2013
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.10 KB | None | 0 0
  1. --[[ /---  |      /--\  /----   |    |    AAA   PPPP  III
  2.      |     |      |  |  \_____  |____|   A   A  P  P   I
  3.      |--   |      |--/       /  |    |   AAAAA  PPPP   I
  4.      |     \----  \---   ---/   |    |   A   A  P     III
  5. ]]--
  6. --Variables
  7. local answer = 0
  8. local result = true
  9.  
  10. --Alias
  11. function calc(a1,a2,a3)
  12.   calculator(a1,a2,a3)
  13. end
  14. function verCheck(a1)
  15.   versionCheck(a1)
  16. end
  17.  
  18. --Help
  19. function help( api )
  20.   print("Usage:")
  21.   result = "help"
  22.   if api == nil then
  23.     printError("flesh.help( api )")
  24.     shell.exit()  
  25.   end
  26.   if api == "openDoor" then
  27.     printError("flesh.openDoor( side door is on or redstone is present. )")
  28.     shell.exit()
  29.   end
  30.   if api == "close Door" then
  31.     printError("flesh.closeDoor( side door is on or redstone is present. )")
  32.     shell.exit()
  33.   end
  34.   if api == "killMe" then
  35.     printError("flesh.killMe( screenX , screenY )")
  36.     shell.exit()
  37.   end
  38.   if api == "calculator" or api == "calc" then
  39.     printError("flesh.calc( first number , operator ( +,-,*,/; @ ) , second number")
  40.     print("@: These are the only operators that you can use right now; I will be adding more in the future.")
  41.   end
  42.   return reslut
  43. end
  44.  
  45. --APIs
  46. function pause( )
  47.   print("Press enter to contunie")
  48.   read()
  49.   return result
  50. end
  51.  
  52. function openDoor( side ) --Open door on a chosen side.
  53.   if side ~= nil then
  54.     result = side .. "rs.on"
  55.     redstone.setOutput( side , true)
  56.     return result
  57.   else
  58.     help("openDoor")
  59.   end
  60. end
  61.  
  62. function closeDoor( side ) --Close door on chosen side.
  63.   if side ~= nil then
  64.     result = side .. "rs.off"
  65.     redstone.setOutput( side , false)
  66.     return result
  67.   else
  68.     help("closeDoor")
  69.   end
  70. end
  71.  
  72. function killMe( screenX , screenY ) --Displays message saying "I'm gona kill you!" on the screen. You must define the screen placement, and it is up to you to clear the screen.
  73.   if screenX ~= nil and screenY ~= nil then
  74.     while scrtPass ~= "liar" do
  75.       result = false
  76.       term.setCursorPos( screenX , screenY )
  77.       printError("I'm gona kill you!")
  78.       scrtPass = read("")
  79.     end
  80.   result = true
  81.   return result
  82.   else
  83.     help("killMe")
  84.   end
  85. end
  86.  
  87. function calculator( num_1 , operator , num_2 )
  88.   if operator == "+" then
  89.     answer = num_1 + num_2
  90.   elseif operator == "-" then
  91.      answer = num_1 - num_2
  92.   elseif operator == "*" then
  93.      answer = num_1 * num_2
  94.   elseif operator == "/" then
  95.     answer = num_1 / num_2
  96.   elseif operator == nil or num_1 == nil or num_2 == nil then
  97.     help("calculator")
  98.   end
  99.   if num_1 ~= nil and num_2 ~= nil and operator ~= nil then
  100.     print( num_1 .. " " .. operator .. " " .. num_2 .. " = " .. answer )
  101.     return answer
  102.   end
  103. end
  104.  
  105. function wrap(name,side)
  106.   _G[name] = peripheral.wrap(side)
  107. end
  108.  
  109. function getMethods(side)
  110.   meths = peripheral.getMethods(side)
  111.   for k,v in pairs(meths) do
  112.     print(k..":"..v)
  113.   end
  114. end
  115.  
  116. function getTime()
  117.   time = textutils.formatTime(os.time())
  118.   return time
  119. end
  120.  
  121. function versionCheck(required)
  122.   version = tonumber(string.sub(os.version(),9))
  123.   if version < required then
  124.     return false
  125.   end
  126. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement