Advertisement
Guest User

room

a guest
Jul 24th, 2017
47
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.02 KB | None | 0 0
  1. os.loadAPI("tur")
  2.  
  3. up = function (hei, front)
  4.     for i=1, hei-1 do
  5.         if front then tur.digSafe() end
  6.         tur.upForce()
  7.     end
  8.     if front then tur.digSafe() end
  9.  tur.downForce(hei-1)
  10. end
  11.  
  12. row = function (len, hei)
  13.     for i=1, len/2 do
  14.         if i ~= 1 then tur.forwardForce(2) end
  15.         up(hei, true)
  16.     end
  17.     if len%2 == 1 then
  18.         tur.forwardForce(2)
  19.         up(hei, false)
  20.         tur.back()
  21.     end
  22.     tur.back(len-2)
  23. end
  24.  
  25. subRoom = function (len, hei, wid, dir)
  26.     for i=1, wid do
  27.         if i~=1 then
  28.             if dir=="right" then
  29.                 tur.strafeRightForce()
  30.             else
  31.                 tur.strafeLeftForce()
  32.             end
  33.         end
  34.         row(len, hei)
  35.     end
  36.     if dir=="right" then
  37.         tur.strafeLeftForce(wid-1)
  38.     else
  39.         tur.strafeRightForce(wid-1)
  40.     end
  41. end
  42.  
  43. args = {...}
  44. wid = args[1]+0
  45. len = args[2]+0
  46. hei = args[3]+0
  47. start = args[4]
  48.  
  49. if start == "right" then
  50.     subRoom(len,hei,wid,"left")
  51. elseif start == "middle" then
  52.     subRoom(len,hei,wid/2+1,"right")
  53.     tur.strafeLeftForce()
  54.     subRoom(len,hei,wid/2,"left")
  55.     tur.strafeRightForce()
  56. else
  57.     subRoom(len,hei,wid,"right")
  58. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement