1
0
Fork 0

Make named fish buckets place fish with a nametag that says that name

fish_bucket_nametag
PrairieWind 2023-06-27 17:16:22 -06:00
parent f335171965
commit ea45d66ee8
1 changed files with 13 additions and 0 deletions

View File

@ -1,4 +1,5 @@
local S = minetest.get_translator(minetest.get_current_modname()) local S = minetest.get_translator(minetest.get_current_modname())
local MAX_MOB_NAME_LENGTH = 30
-- Fish Buckets -- Fish Buckets
local fish_names = { local fish_names = {
@ -29,6 +30,18 @@ local function on_place_fish(itemstack, placer, pointed_thing)
if props ~= "" then if props ~= "" then
o:set_properties(minetest.deserialize(props)) o:set_properties(minetest.deserialize(props))
end end
local ent = o:get_luaentity()
-- set nametag
local nametag = itemstack:get_meta():get_string("name")
if nametag ~= "" then
if string.len(nametag) > MAX_MOB_NAME_LENGTH then
nametag = string.sub(nametag, 1, MAX_MOB_NAME_LENGTH)
end
ent.nametag = nametag
ent:update_tag()
end
local water = "mcl_core:water_source" local water = "mcl_core:water_source"
if n.name == "mclx_core:river_water_source" then if n.name == "mclx_core:river_water_source" then
water = n.name water = n.name