Advertisement
antonsavov

WIP MinecraftGetter

Jan 4th, 2018
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.15 KB | None | 0 0
  1. -------------------------------
  2. -- /lib/MinecraftGetter
  3. -------------------------------
  4. --- This package keeps all functions that are getting data from minecraft:
  5. -- get player location, getting scoreboard data, ...
  6. -- the rest of twenty-k code should not use Minecraft commands directly but only through this package
  7.  
  8. local mc = {}
  9. mcget = mc
  10.  
  11. --- Returns a table with the coordinates of the computer running this script
  12. function mc.computerPosition()
  13.     local ox,oy,oz = commands.getBlockPosition()
  14.     local T = {
  15.         x = ox,
  16.         y = oy,
  17.         z = oz
  18.     }
  19.     return T
  20. end
  21.  
  22. --- Checks if a specified block is at the specified locaiton
  23. -- block can be passed as table with .block and .variant
  24. -- or as a string for testing for block kind of all its variants
  25. function mc.testForBlock(x,y,z,block)
  26.     local isblock = false
  27.     local message
  28.     if type(block) == 'table' then
  29.         isblock, message = commands.testforblock(x,y,z,block.block,block.variant)
  30.     elseif type(block) == 'string' then
  31.         isblock, message = commands.testforblock(x,y,z,block)
  32.     end
  33.     --debug.log("commands.testforblock returned: isblock >"..isblock.."<, message >"..message.."<")
  34.     return isblock
  35. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement