-
-
Save GreenXenith/be409cc9ff13dc9a6daa05e3ef9ec2fd to your computer and use it in GitHub Desktop.
lbm
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- 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