mirror of
https://git.minetest.land/VoxeLibre/VoxeLibre.git
synced 2024-11-09 09:41:05 +01:00
39 lines
No EOL
919 B
Lua
39 lines
No EOL
919 B
Lua
-- Code to execute before custom on_rightclick handling
|
|
local on_rightclick_prefix = function(self, clicker)
|
|
local item = clicker:get_wielded_item()
|
|
|
|
-- Name mob with nametag
|
|
if not self.ignores_nametag and item:get_name() == "mcl_mobs:nametag" then
|
|
|
|
local tag = item:get_meta():get_string("name")
|
|
if tag ~= "" then
|
|
if string.len(tag) > MAX_MOB_NAME_LENGTH then
|
|
tag = string.sub(tag, 1, MAX_MOB_NAME_LENGTH)
|
|
end
|
|
self.nametag = tag
|
|
|
|
update_tag(self)
|
|
|
|
if not mobs.is_creative(clicker:get_player_name()) then
|
|
item:take_item()
|
|
clicker:set_wielded_item(item)
|
|
end
|
|
return true
|
|
end
|
|
|
|
end
|
|
return false
|
|
end
|
|
|
|
mobs.create_mob_on_rightclick = function(on_rightclick)
|
|
return function(self, clicker)
|
|
local stop = on_rightclick_prefix(self, clicker)
|
|
if (not stop) and (on_rightclick) then
|
|
on_rightclick(self, clicker)
|
|
end
|
|
end
|
|
end
|
|
|
|
mobs.feed_tame = function(self)
|
|
return nil
|
|
end |