Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local WindMill = {}
- local WindMillAng = 0
- local bladeInfo = {
- [1] = { 0, 1 }, -- Top blade
- [2] = { 1, 0 }, -- Right blade
- [3] = { 0, -1 }, -- Bottom blade
- [4] = { -1, 0 } -- Left blade
- }
- FACING_FORWARD = 0
- FACING_RIGHT = math.pi / 2
- FACING_BACK = math.pi
- FACING_LEFT = (math.pi / 2) * 3
- function DoWindmillArms(id, x, y, z, ang, facing )
- local bladeLength = 1
- local cMgr = core.ChunkManager
- for k=1, #WindMill do
- cMgr:SetBlock(WindMill[k].x, WindMill[k].y, WindMill[k].z, 0, core.EntityManager:GetPlayers())
- end
- WindMill = {}
- for i = 1, 4 do
- for j = 1, bladeLength do
- local bX = bladeInfo[i][1] * j
- local bY = bladeInfo[i][2] * j
- bX = math.floor(bX * math.cos( ang ) - bY * math.sin( ang ) + 0.5)
- bY = math.floor(bX * math.sin( ang ) + bY * math.cos( ang ) + 0.5)
- local blockX = math.floor(x + (bX * math.cos( facing )) + 0.5)
- local blockY = math.floor(y + bY + 0.5)
- local blockZ = math.floor(z + (-bX * math.sin( facing)) + 0.5)
- table.insert( WindMill, { x = blockX, y = blockY, z = blockZ } )
- cMgr:SetBlock( blockX, blockY, blockZ, ITEM_WOOD, core.EntityManager:GetPlayers() )
- end
- end
- end
- function def.PlayerClickBlock( ply, x, y, z, blockid )
- -- Called when the player left clicks a block
- -- Return true to not handle the dig event
- local cMgr = core.ChunkManager
- if (blockid ~= ITEM_LOG) then
- cMgr:SetBlock(x, y, z, 0, core.EntityManager:GetPlayers())
- end
- if (blockid == ITEM_LOG) then
- local WindMillID = #WindMill + 1
- if (cMgr:GetBlockID(x, y, z + 1) == ITEM_LOG) then
- DoWindmillArms(WindMillID, x, y, z, WindMillAng, FACING_BACK )
- WindMillAng = WindMillAng + (math.pi / 4)
- end
- end
- if (blockid == 78) then
- local held = ply:GetHeldItemID()
- if (held == ITEM_WOOD_SPADE
- or held == ITEM_STONE_SPADE
- or held == ITEM_IRON_SPADE
- or held == ITEM_GOLD_SPADE
- or held == ITEM_DIAMOND_SPADE) then
- cMgr:SetBlock(x, y, z, 0, core.EntityManager:GetPlayers())
- cMgr:SpawnItem( 332, x, y, z )
- return true
- end
- end
- if (blockid == 46) then
- cMgr:DoExplosion( x, y, z, 4, core.EntityManager:GetPlayers())
- return true
- end
- return false
- end
Advertisement
Add Comment
Please, Sign In to add comment