Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Equation Builder:
- --Initialize:
- turtle.select(2)
- --Printables:
- io.write("Input equation, increment size, number of dimensions, parameters, limits first dimension (lower upper), limits second dimension (lower upper), limits third dimension (lower upper)")
- --Input equation: 1 for ellipse, 2 for parabola, 3 for etc
- --Parameters is table of form: {a,b,c,d,e}
- --Wireless Connection:
- --Not yes
- --Variables:
- Args = {...}
- --Parameters:
- InputEquation = tonumber(Args[1])
- i = tonumber(Args[2]) --Incrementer
- dim = tonumber(Args[3])
- Zmax = tonumber(Args[10])
- Zmin = tonumber(Args[9])
- Z = {}
- Xmax = tonumber(Args[6])
- Xmin = tonumber(Args[5])
- X = Xmin
- if dim > 2 then
- Ymax = tonumber(Args[8])
- Ymin = tonumber(Args[7])
- Y = Zmin
- end
- a = Args[11]
- b = Args[12]
- c = Args[13]
- d = Args[14]
- e = Args[15]
- locX = Xmin
- locZ = Zmin
- Zx = {}
- Yx = {}
- u = 2 --Basic slot selection
- closetoHome = 1 --Close to start
- --Functions:
- function EqZ(Xc)
- if InputEquation == 1 then
- if dim == 2 then
- return (b/a)*math.sqrt(a^2-Xc^2) --Rewriten Ellipse of form "x^2/a^2+y^2/b^2==1"
- elseif dim == 3 then
- end
- elseif InputEquation == 2 then
- elseif InputEquation == 3 then
- end
- end
- --Refuels turtle
- function TurtleRefuel() --Refuel
- if turtle.getFuelLevel() < 320 and turtle.getItemCount(1) > 3 then
- turtle.select(1)
- turtle.refuel(3)
- print("TurtleRefueling")
- end
- turtle.select(u)
- end
- --Item slot selection , for block selection (ignores first item slot which is usually reserved for fuel)
- function SlotSelection()
- if turtle.getItemCount(u) == 0 then
- for k=1,16 do
- if turtle.getItemCount(u) == 0 then
- if u < 16 then
- u=u+1
- turtle.select(u)
- else
- turtle.select(2)
- u=2
- end
- end
- end
- end
- end
- --Place underneath (down) block (even on water and lava)
- function BlockplaceDown()
- SlotSelection()
- if turtle.detectDown() then
- bool,data = turtle.inspectDown()
- if data.name == "minecraft:lava" and data.name == "minecraft:water" and data.name == "minecraft:flowing_water" and data.name == "minecraft:flowing_lava" then
- turtle.placeDown()
- end
- else
- turtle.placeDown()
- end
- end
- --graveldigforward
- function graveldig() --Gravel Shield for digging and the digging
- os.sleep(9/20)
- if turtle.detect() then
- bool,data=turtle.inspect()
- while data.name ~= "minecraft:flowing_water" and data.name ~= "minecraft:flowing_lava" and turtle.inspect()~= false do
- turtle.dig()
- os.sleep(9/20)
- bool,data=turtle.inspect()
- end
- end
- end
- --Forward (in front) dig if something is detected (NO GRAVEL SHIELD!!!)
- function Fdig()
- if turtle.detect() then
- turtle.dig()
- end
- end
- --Dig N move
- function dignmove()
- Fdig()
- graveldig()
- turtle.forward()
- end
- function round(num)
- return math.floor(num+0.5)
- end
- --Max value in a table
- function maxtab(a)
- local values = {}
- for k,v in pairs(a) do
- values[#values+1] = v
- end
- table.sort(values)
- return values[#values]
- end
- --Code:
- while X < Xmax do
- print("Table Filling")
- table.insert(Zx,X/i,EqZ(X)) --Filling in the locations of the blocks in the table
- X = X + i --Upcounting of the increment
- if dim == 3 then
- while Z < Zmax do
- Yz[Eqy] = Z --Filling in the locations of the blocks in the table
- Z = Z + i --Upcounting of the increment
- end
- end
- end
- tabZmax = maxtab(Zx)
- while locZ < tabZmax do
- print("Strip building")
- while locX < Xmax and locX >= Xmin do
- for Xpos = (locX-0.5)/i, (locX+0.5)/i , 1 do
- if Zx[Xpos] ~= nil then
- if round(Zx[Xpos]) == locZ or round(Zx[Xpos]) == -locZ or math.floor(Zx[Xpos]) == locZ or math.ceil(Zx[Xpos]) == locZ or math.floor(Zx[Xpos]) == -locZ or math.ceil(Zx[Xpos]) == -locZ then
- print("Will place a block")
- BlockplaceDown() --Does NOT replace blocks (except water/lava)
- placed = 1
- end
- end
- print(Zx[Xpos])
- end
- dignmove()
- TurtleRefuel()
- print("X:",locX," Z:",locZ, "EqZ: ", EqZ(locX))
- locX = locX + 1 --Keeps track of the X coordinate
- end
- if math.fmod(locZ,2) == 0 and locZ < tabZmax then --Turn around at the end of a 'strip'
- turtle.turnLeft()
- dignmove()
- turtle.turnLeft()
- closetoHome = 0 --Far away from start
- else
- turtle.turnRight()
- dignmove()
- turtle.turnRight()
- closetoHome = 1 --Close to start
- end
- locX = Xmin + 1
- locZ = locZ + 1 --Keeps track of the Z coordinate change in the math.mod block
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement