Add rightclick factions hook

This commit is contained in:
sapier 2013-08-21 20:46:11 +02:00
parent 341d799bbf
commit 9a15516d7e
3 changed files with 42 additions and 2 deletions

View File

@ -72,3 +72,34 @@ function mobf_factions.setupentity(entity)
end end
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

View File

@ -397,6 +397,13 @@ function mobf_init_modules()
handler = mobf_path.mob_rightclick_callback, handler = mobf_path.mob_rightclick_callback,
configcheck = mobf_path.config_check 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 end
mobf_init_framework() mobf_init_framework()

View File

@ -310,7 +310,6 @@ function mobf.activate_handler(self,staticdata)
mobf.init_on_step_callbacks(self,now) mobf.init_on_step_callbacks(self,now)
mobf.init_on_punch_callbacks(self,now) mobf.init_on_punch_callbacks(self,now)
mobf.init_on_rightclick_callbacks(self,now)
--initialize ride support --initialize ride support
mobf_ride.init(self) mobf_ride.init(self)
@ -419,12 +418,15 @@ function mobf.activate_handler(self,staticdata)
--join factions --join factions
mobf.init_factions(self) mobf.init_factions(self)
--custom on activate handler --custom on activate handler
if (self.data.generic.custom_on_activate_handler ~= nil) then if (self.data.generic.custom_on_activate_handler ~= nil) then
self.data.generic.custom_on_activate_handler(self) self.data.generic.custom_on_activate_handler(self)
end end
--check may need data present after initialization has completed
mobf.init_on_rightclick_callbacks(self,now)
--add lifebar --add lifebar
if minetest.world_setting_get("mobf_lifebar") then if minetest.world_setting_get("mobf_lifebar") then
self.lifebar = mobf_lifebar.add(self) self.lifebar = mobf_lifebar.add(self)