Find out BlockID on Cords
#1
Hello,
how i can find out the blockID on Cords for example PlayerSpawnPoint?
Reply
Thanks given by:
#2
world:GetBlock(lastBedPos.x, lastBedPos.y, lastBedPos.z)
Reply
Thanks given by:
#3
Note that this function only works as expected if the chunk which you're querying is loaded. If you have a reasonable doubt that the chunk may be unloaded, you'll need to use the cWorld:ChunkStay() method to force-load it.
Reply
Thanks given by: moiko89
#4
Like this?
PHP Code:
function LoadMyChunk(X,Z,World)
    
World:ChunkStay({{math.floor(16), math.floor(16)}}, nil,
                        function()
                                
_Height World:TryGetHeight(XZ)
                                print(
XHeightZ_)
                        
end
                
)
end 

Or you know a simpler way?
Reply
Thanks given by:
#5
(05-14-2017, 03:47 AM)xoft Wrote: Note that this function only works as expected if the chunk which you're querying is loaded. If you have a reasonable doubt that the chunk may be unloaded, you'll need to use the cWorld:ChunkStay() method to force-load it.

I have two function with a little difference. But the first one works fine and the other one works not. In the first function (LoadBedBlock) can i use "Height" out of the inner function and in GetRandomHeight i cant use "Height" out of the inner function, why?

Result:  LoadBedBlock         Height: 64       IsLaoded:      true

PHP Code:
function LoadBedBlock(X,Y,Z,World)
    
local _Height
    local BedBlock
    World
:ChunkStay({{math.floor(16), math.floor(16)}}, nil,
                        function()
                                
_Height World:TryGetHeight(XZ)
                                --print(
XHeightZ_)
                        
end
    
)
    print(
"LoadBedBlock ","Height:",Height," IsLaoded:",_)
    
BedBlock=World:GetBlock(XYZ)
    return 
BedBlock
end 


Result: GetRandomHeight         Height: nil      IsLaoded:      nil

PHP Code:
function GetRandomHeight(X,Z,World)
    
local _Height
    World
:ChunkStay({{math.floor(16), math.floor(16)}}, nil,
                        function()
                                
_Height World:TryGetHeight(XZ)
                                --print(
XHeightZ_)
                        
end
    
)
    print(
"GetRandomHeight ","Height:",Height," IsLaoded:",_)
    return 
Height
end 
Reply
Thanks given by:
#6
No, these won't work reliably. Once the callback given to ChunkStay finishes, Cuberite is free to unload the chunk again. Whatever processing you need to do, you need to do it in the ChunkStay's callback function. So the World:GetBlock() call in your first function may still return "chunk unloaded".

Note that naming a variable "_" in Lua basically means "drop this value, I'm not interested in it". You need to give a proper name to the variable if you want to use it.

True, I still don't know why exactly your code isn't working. If you uncomment the print() calls in the callbacks, do they print the correct values?
Reply
Thanks given by:




Users browsing this thread: 1 Guest(s)