How to get block at coordinates? - Printable Version +- Cuberite Forum (https://forum.cuberite.org) +-- Forum: Cuberite (https://forum.cuberite.org/forum-4.html) +--- Forum: Development (https://forum.cuberite.org/forum-13.html) +--- Thread: How to get block at coordinates? (/thread-3349.html) |
How to get block at coordinates? - _XxFedexX_ - 04-12-2021 Basically I want to check the block below the player. If it is stairs or piston, return true; else return false. I checked in the API but didn't found anything that could do this. Thank you. Post Scriptum: sorry for bad English, i am not mother language. RE: How to get block at coordinates? - NiLSPACE - 04-12-2021 You can do it with this code: local blocktype = world:GetBlock(player:GetPosition():addedY(-1)); RE: How to get block at coordinates? - _XxFedexX_ - 04-12-2021 (04-12-2021, 09:07 PM)NiLSPACE Wrote: You can do it with this code: I get error attempt to index local 'PlayerWorld' (a nil value) with this code: 33 function testBlock(aPlayer, OldPosition, NewPosition) 34 local PlayerWorld = OldPosition.world -- I get error here 35 local block = PlayerWorld:GetBlock(aPlayer:GetPosition():addedY(-1))[/font] 36 end And thank you for your support! RE: How to get block at coordinates? - 12xx12 - 04-12-2021 (04-12-2021, 11:30 PM)_XxFedexX_ Wrote:(04-12-2021, 09:07 PM)NiLSPACE Wrote: You can do it with this code: The Position object doesn't know it's world. it's only three values. You need to ask the player object for it's world 34 local PlayerWorld = Player:GetWorld() |