callback DoWithBlockEntityAt why not work
#11
(08-30-2016, 01:43 AM)as123456 Wrote: Not the reason!

Show your updated code
Reply
Thanks given by:
#12
(08-30-2016, 01:44 AM)DrMasik Wrote:
(08-30-2016, 01:43 AM)as123456 Wrote: Not the reason!

Show your updated code

Code:
function OnPlayerRightClick(Player, BlockX, BlockY, BlockZ, BlockFace, CursorX, CursorY, CursorZ)
    
    local world=Player:GetWorld()

    world:DoWithBlockEntityAt(BlockX, BlockY, BlockZ,
    function  (a_BlockEntity)
    LOG("a_BlockEntity")
    LOG(a_BlockEntity.GetBlockType)
    end
    
    )
    LOG("End")
    return false
end
Reply
Thanks given by:
#13
Not other


Attached Files Thumbnail(s)
   
Reply
Thanks given by:
#14
(08-30-2016, 01:47 AM)as123456 Wrote:
Code:
function OnPlayerRightClick(Player, BlockX, BlockY, BlockZ, BlockFace, CursorX, CursorY, CursorZ)
    
    local world=Player:GetWorld()

    world:DoWithBlockEntityAt(BlockX, BlockY, BlockZ,
    function  (a_BlockEntity)
    LOG("a_BlockEntity")
    LOG(a_BlockEntity.GetBlockType)
    end
    
    )
    LOG("End")
    return false
end

You must start from "function Initialize(Plugin)" functon, register hooks in the function. Plugin starts from the "function Initialize(Plugin)" function.So, I post simple plugin template code:
Code:
function Initialize(Plugin)
 Plugin:SetName("Private")
 Plugin:SetVersion(20151231)
 LOG(MsgSuffix .. Plugin:GetName() .. " initialize...")

 -- Register hooks
 cPluginManager.AddHook(cPluginManager.HOOK_PLAYER_RIGHT_CLICK, MyOnPlayerRightClick);

 -- Load the InfoReg shared library:
 dofile(cPluginManager:GetPluginsPath() .. "/InfoReg.lua")

 -- Nice message :)
 LOG(MsgSuffix .. "Initialized " .. Plugin:GetName() .. " v." .. Plugin:GetVersion())

 return true
end

function MyOnPlayerRightClick(..)
-- Do what you want

 return false;
end
Reply
Thanks given by:
#15
Not the case!but 3q
Reply
Thanks given by:
#16
There probably isn't a blockentity there. What block are you clicking on? Blockentities are things like chests, furnaces, signs and that sort of stuff.
Reply
Thanks given by:
#17
(08-30-2016, 02:52 AM)NiLSPACE Wrote: There probably isn't a blockentity there. What block are you clicking on? Blockentities are things like chests, furnaces, signs and that sort of stuff.

trees,crop and other block,but fail 
Reply
Thanks given by:
#18
Are you activate (load) the plugin? If yes - put up all your code, settings.ini file and server directory listing including sub directories and files
Reply
Thanks given by:
#19
Neither trees nor crops have a blockentity attached to them at all.

What is it that you're trying to achieve anyway? Perhaps you're using the wrong approach here.
Reply
Thanks given by:
#20
You're confusing blockentities with blocks. Use "Player:GetWorld():GetBlock(BlockX, BlockY, BlockZ)" in order to get the block id of the clicked block.
Reply
Thanks given by:




Users browsing this thread: 2 Guest(s)