Skip to content

Instantly share code, notes, and snippets.

@GreenXenith GreenXenith/init.lua Secret
Last active Nov 1, 2017

Embed
What would you like to do?
lbm
-- Inside the nodedef:
after_place_node = function(pos, placer, itemstack, pointed_thing)
local meta = minetest.get_meta(pos)
local owner = placer:get_player_name()
meta:set_string("owner", owner)
meta:set_string("infotext", owner.."'s Stocking")
local inv = meta:get_inventory()
inv:set_size("main", 8*2)
meta:set_int("filled", 0),
placer:set_attribute("has_placed_stocking", "true")
end,
-- LBM (and chat cmd):
minetest.register_chatcommand("lbm_on", {
privs = {protection_bypass = true},
func = function(name, param)
local enable_stocking_lbm = true
end
})
if enable_stocking_lbm = true then
minetest.register_lbm({
label = "Fill stockings",
name = "christmas_decor:fill_stockings",
nodenames = {"christmas_decor:stocking"},
run_at_every_load = false,
action = function(pos, node)
local meta = minetest.get_meta(pos)
local inv = meta:get_inventory()
local stuffers = stuffer.select_stuffers()
if meta:get_int("filled") == 0 then
for i=1, #stuffers do
inv:set_stack("main", i, stuffers[i])
end
meta:set_int("filled", 1)
else
return
end
end,
})
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.