Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- R= {}
- R.status= false
- R.X= 0
- R.Y= 0
- R.Z= 0
- R.Side= 0
- R.SOUTH= 0 -- юг +z
- R.EAST= 3 -- восток +x
- R.NORTH= 2 -- север -z
- R.WEST= 1 -- запад -x
- function new(x,y,z,side)
- R.X= x
- R.Y= y
- R.Z= z
- R.Side= side
- R.f= turtle.forward
- R.tr= turtle.turnRight
- R.tl= turtle.turnLeft
- R.tu= turtle.up
- R.td= turtle.down
- turtle.forward= R.forward
- turtle.turnRight= R.tRight
- turtle.turnLeft= R.tLeft
- turtle.up= R.tUp
- turtle.down= R.tDown
- R.status= true
- return R
- end
- function R.draw()
- if (R.status == false) then error('initialize object') end
- print(R.X,' ',R.Y,' ',R.Z,' ',R.Side)
- end
- function R.forward()
- if (R.status == false) then error('initialize object') end
- if (R.f()) then
- if (Side == 0) then
- R.Z= R.Z+1
- end
- if (R.Side == 1) then
- R.X= R.X-1
- end
- if (R.Side == 2) then
- R.Z= R.Z-1
- end
- if (R.Side == 3) then
- R.X= R.X+1
- end
- end
- end
- function R.tRight()
- if (R.status == false) then error('initialize object') end
- R.Side= R.Side+1
- R.tr()
- if (R.Side > 3) then R.Side= 0 end
- end
- function R.tLeft()
- if (R.status == false) then error('initialize object') end
- R.Side= Side-1
- R.tl()
- if (R.Side < 0) then R.Side= 3 end
- end
- function R.tUp()
- if (R.status == false) then error('initialize object') end
- if (R.tu()) then
- R.Y= R.Y+1
- end
- end
- function R.tDown()
- if (R.status == false) then error('initialize object') end
- if (R.td()) then
- R.Y= R.Y-1
- end
- end
- function R.getX()
- if (R.status == false) then error('initialize object') end
- if (R.X ~= nil) then return R.X else return 0 end
- end
- function R.getY()
- if (R.status == false) then error('initialize object') end
- if (R.Y ~= nil) then return R.Y else return 0 end
- end
- function R.getZ()
- if (R.status == false) then error('initialize object') end
- if (R.Z ~= nil) then return R.Z else return 0 end
- end
- function R.goto(tox,toy,toz,side)
- if (R.status == false) then error('initialize object') end
- while true do
- R.draw()
- if (toy > R.Y) then turtle.digUp() turtle.up() end
- if (toy < R.Y) then turtle.digDown() turtle.down() end
- if (toy == R.Y) then break end
- end
- while true do
- if (tox > R.X) then R.turnSide(3) turtle.dig() turtle.forward() end
- if (tox < R.X) then R.turnSide(1) turtle.dig() turtle.forward() end
- if (tox == R.X) then break end
- end
- while true do
- if (toz > R.Z) then R.turnSide(0) turtle.dig() turtle.forward() end
- if (toz < R.Z) then R.turnSide(2) turtle.dig() turtle.forward() end
- if (toz == R.Z) then break end
- end
- R.turnSide(side)
- end
- function R.digLeft()
- if (R.status == false) then error('initialize object') end
- turtle.turnLeft()
- turtle.dig()
- turtle.turnRight()
- end
- function R.digRight()
- if (R.status == false) then error('initialize object') end
- turtle.turnRight()
- turtle.dig()
- turtle.turnLeft()
- end
- function R.turnSide(sides)
- if (R.status == false) then error('initialize object') end
- while true do
- if (R.Side == sides) then
- break
- end
- turtle.turnRight()
- end
- end
- function R.close()
- if (R.status == false) then error('initialize object') end
- turtle.forward= R.f
- turtle.turnRight= R.tr
- turtle.turnLeft= R.tl
- turtle.up= R.tu
- turtle.down= R.td
- R.status= false
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement