Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local bladeInfo = {
- [1] = { 0, 1 }, -- Top blade
- [2] = { 1, 0 }, -- Right blade
- [3] = { 0, -1 }, -- Bottom blade
- [3] = { -1, 0 } -- Left blade
- }
- FACING_FORWARD = 0
- FACING_RIGHT = math.pi / 2
- FACING_BACK = math.pi
- FACING_LEFT = (math.pi / 2) * 3
- function DoWindmillArms( x, y, z, ang, facing )
- -- This function assumes the previous blocks of the windmill blades have already been cleared
- -- x, y, z is the origin - the center of the windmill blades
- -- ang is the angle of the entire windmill
- -- facing is the direction the windmill is facing, on the y axis
- local bladeLength = 1
- for i=1, 4 do -- For each blade
- -- i is the blade ID
- for j=1, bladeLength do -- For each block along the blade
- -- Get the block coordinate along the blade, if the windmill was at angle 0
- local bX = bladeInfo[i][1] * j
- local bY = bladeInfo[i][2] * j
- -- Now, we'll rotate the coordinate by ang
- bX = bX * math.cos( ang ) - bY * math.sin( ang )
- bY = bX * math.sin( ang ) + bY * math.cos( ang )
- -- Finally, calculate the absolute block coordinates
- local blockX = x + (bX * math.cos( facing ))
- local blockY = y + bY
- local blockZ = z + (-bX * math.sin( facing))
- -- We have a block coordinate!
- -- TODO: Call function to set block ID to wood (or whatever) here
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment