From 9a15516d7efbabd9b5ad8e45ad6ca87ce11f9dc9 Mon Sep 17 00:00:00 2001 From: sapier Date: Wed, 21 Aug 2013 20:46:11 +0200 Subject: [PATCH] Add rightclick factions hook --- mobf/factions.lua | 31 +++++++++++++++++++++++++++++++ mobf/init.lua | 7 +++++++ mobf/mobf.lua | 6 ++++-- 3 files changed, 42 insertions(+), 2 deletions(-) diff --git a/mobf/factions.lua b/mobf/factions.lua index db7eeb2..ffab1c4 100644 --- a/mobf/factions.lua +++ b/mobf/factions.lua @@ -72,3 +72,34 @@ function mobf_factions.setupentity(entity) end end + +------------------------------------------------------------------------------- +-- name: mob_rightclick_callback(entity,player) +-- +--! @brief show factions rightclick menu +--! @memberof mobf_factions +-- +--! @param entity to modify +--! @param player issuing rightclick +-- +------------------------------------------------------------------------------- +function mobf_factions.mob_rightclick_callback(entity,player) +end + + +------------------------------------------------------------------------------- +-- name: mob_rightclick_callback(entity,player) +-- +--! @brief show factions rightclick menu +--! @memberof mobf_factions +-- +--! @param entity clicked +-- +------------------------------------------------------------------------------- +function mobf_factions.config_check(entity) + print("checking for spawner: " .. dump(entity.dynamic_data.spawning.spawner)) + if entity.dynamic_data.spawning.spawner ~= nil then + return true + end + return false +end \ No newline at end of file diff --git a/mobf/init.lua b/mobf/init.lua index bf51ec0..0da7073 100644 --- a/mobf/init.lua +++ b/mobf/init.lua @@ -397,6 +397,13 @@ function mobf_init_modules() handler = mobf_path.mob_rightclick_callback, configcheck = mobf_path.config_check }) + + mobf.register_on_rightclick_callback({ + name = "factions", + visiblename = "Factions", + handler = mobf_factions.mob_rightclick_callback, + configcheck = mobf_factions.config_check + }) end mobf_init_framework() diff --git a/mobf/mobf.lua b/mobf/mobf.lua index 5af9651..ee31c5e 100644 --- a/mobf/mobf.lua +++ b/mobf/mobf.lua @@ -310,7 +310,6 @@ function mobf.activate_handler(self,staticdata) mobf.init_on_step_callbacks(self,now) mobf.init_on_punch_callbacks(self,now) - mobf.init_on_rightclick_callbacks(self,now) --initialize ride support mobf_ride.init(self) @@ -419,12 +418,15 @@ function mobf.activate_handler(self,staticdata) --join factions mobf.init_factions(self) - + --custom on activate handler if (self.data.generic.custom_on_activate_handler ~= nil) then self.data.generic.custom_on_activate_handler(self) end + --check may need data present after initialization has completed + mobf.init_on_rightclick_callbacks(self,now) + --add lifebar if minetest.world_setting_get("mobf_lifebar") then self.lifebar = mobf_lifebar.add(self)