Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- The Hexagon code is still a little quirky when smaller than side length 10, but hey, it works
- -- I copy and pasted the movement functions from shape.lua so integrating should be a snap :)
- -- I am pretty happy I did this all in a day! I didn't include this in my local shape.lua and send a pull request
- -- I will do that in the morning unless you have put it into yours already
- -- Please note that round() is necessary to resolve irrational decimals to the minecraft block grid in both shapes
- function round(num, idp)
- local mult = 10^(idp or 0)
- return math.floor(num * mult + 0.5) / mult
- end
- function hexagon(sideLength)
- local changex = sideLength / 2
- local changey = round(math.sqrt(3) * changex, 0)
- changex = round(changex, 0)
- local counter = 0
- navigateTo(changex, 0)
- for currentSide = 1, 6 do
- counter = 0
- if currentSide == 1 then
- for placed = 1, sideLength do
- navigateTo(positionx + 1, positiony)
- placeBlock()
- end
- elseif currentSide == 2 then
- navigateTo(positionx, positiony + 1)
- while positiony <= changey do
- if counter == 0 or counter == 2 or counter == 4 then
- navigateTo(positionx + 1, positiony)
- end
- placeBlock()
- navigateTo(positionx, positiony + 1)
- counter = counter + 1
- if counter == 5 then
- counter = 0
- end
- end
- elseif currentSide == 3 then
- while positiony <= (2 * changey) do
- if counter == 0 or counter == 2 or counter == 4 then
- navigateTo(positionx - 1, positiony)
- end
- placeBlock()
- navigateTo(positionx, positiony + 1)
- counter = counter + 1
- if counter == 5 then
- counter = 0
- end
- end
- elseif currentSide == 4 then
- for placed = 1, sideLength do
- navigateTo(positionx - 1, positiony)
- placeBlock()
- end
- elseif currentSide == 5 then
- navigateTo(positionx, positiony - 1)
- while positiony >= changey do
- if counter == 0 or counter == 2 or counter == 4 then
- navigateTo(positionx - 1, positiony)
- end
- placeBlock()
- navigateTo(positionx, positiony - 1)
- counter = counter + 1
- if counter == 5 then
- counter = 0
- end
- end
- elseif currentSide == 6 then
- while positiony >= 0 do
- if counter == 0 or counter == 2 or counter == 4 then
- navigateTo(positionx + 1, positiony)
- end
- placeBlock()
- navigateTo(positionx, positiony - 1)
- counter = counter + 1
- if counter == 5 then
- counter = 0
- end
- end
- end
- end
- navigateTo(0, 0)
- while facing ~= 0 do
- turnLeftTrack()
- end
- end
- function octagon(sideLength)
- local sideLength2 = sideLength - 1
- local change = round(sideLength2 / math.sqrt(2), 0)
- navigateTo(change, 0)
- for currentSide = 1, 8 do
- if currentSide == 1 then
- for placed = 1, sideLength2 do
- navigateTo(positionx + 1, positiony)
- placeBlock()
- end
- elseif currentSide == 2 then
- for placed = 1, change do
- navigateTo(positionx + 1, positiony + 1)
- placeBlock()
- end
- elseif currentSide == 3 then
- for placed = 1, sideLength2 do
- navigateTo(positionx, positiony + 1)
- placeBlock()
- end
- elseif currentSide == 4 then
- for placed = 1, change do
- navigateTo(positionx - 1, positiony + 1)
- placeBlock()
- end
- elseif currentSide == 5 then
- for placed = 1, sideLength2 do
- navigateTo(positionx - 1, positiony)
- placeBlock()
- end
- elseif currentSide == 6 then
- for placed = 1, change do
- navigateTo(positionx - 1, positiony - 1)
- placeBlock()
- end
- elseif currentSide == 7 then
- for placed = 1, sideLength2 do
- navigateTo(positionx, positiony - 1)
- placeBlock()
- end
- elseif currentSide == 8 then
- for placed = 1, change do
- navigateTo(positionx + 1, positiony - 1)
- placeBlock()
- end
- end
- end
- navigateTo(0, 0)
- while facing ~= 0 do
- turnLeftTrack()
- end
- end
- function hexPrism(sideLength, height)
- for z = 1, height do
- hexagon(sideLength)
- safeUp()
- end
- end
- function octPrism(sideLength, height)
- for z = 1, height do
- octagon(sideLength)
- safeUp()
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment