moverperfect

floor

Oct 6th, 2012
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.87 KB | None | 0 0
  1. -- Floor script
  2. -- Needs murtle to work
  3.  
  4. local arg = {...}
  5. if arg == nil then
  6.     print("Usage: floor <z-size> <x-size> <side(1-place down(default) 2-place up)>")
  7.     return 2
  8. end
  9.  
  10. z = tonumber (arg[1])
  11. x = tonumber (arg[2])
  12. side = tonumber(arg[3])
  13.  
  14. path=shell.resolveProgram("murtle")
  15. if path==nil or not os.loadAPI(path) then
  16.   print("Cant load library: murtle")
  17.   return 1
  18. end
  19.  
  20. function place()
  21.     if side == nil or side == 1 then
  22.         murtle.placedown()
  23.     elseif side == 2 then
  24.         murtle.placeup()
  25.     end
  26. end
  27.  
  28. if murtle.checkeven(x) then
  29.     repet = x/2
  30.     prop = 0
  31. else
  32.     repet = (x-1)/2
  33.     prop = 1
  34. end
  35.  
  36. for i=1, repet do
  37.     place()
  38.     for f=1, z-1 do
  39.         murtle.fwd()
  40.         place()
  41.     end
  42.     murtle.turnright()
  43.     place()
  44.     for f=1, z-1 do
  45.         murtle.fwd()
  46.         place()
  47.     end
  48.     murtle.turnleft()
  49. end
  50.  
  51. for a=1, prop do
  52.     place()
  53.     for i=1, z-1 do
  54.         murtle.fwd()
  55.         place()
  56.     end
  57. end
Advertisement
Add Comment
Please, Sign In to add comment