1 local armor_parts = {"head", "torso", "legs", "feet"}
2 skycraft.armor_list = {}
3 for _, n in pairs(armor_parts) do
4 skycraft.armor_list[n] = skycraft.register_group_list("armor_" .. n)
6 skycraft.head_list = skycraft.register_group_list("head")
8 function skycraft.place_and_fill_armor_stand(pos, player)
9 minetest.set_node(pos, {name = "mcl_armor_stand:armor_stand"})
10 local nodedef = minetest.registered_nodes["mcl_armor_stand:armor_stand"]
11 local node = minetest.get_node(pos)
12 local armor_pieces = {}
13 for _, n in pairs(armor_parts) do
14 local piece_list = skycraft.armor_list[n]
15 table.insert(armor_pieces, ItemStack(piece_list[math.random(#piece_list)]))
17 local function equip_armor(i)
18 local piece = armor_pieces[i]
19 if not piece then return end
20 nodedef.on_rightclick(pos, node, player, ItemStack(piece))
21 minetest.after(0.5, equip_armor, i + 1)
23 minetest.after(0.5, equip_armor, 1)
26 minetest.register_chatcommand("armorstand", {
27 description = "Spawn an armor stand at your position and fill it with random armor",
28 privs = {server = true},
30 local player = minetest.get_player_by_name(name)
31 if not player then return false, "You have to be online to use this command" end
32 skycraft.place_and_fill_armor_stand(vector.floor(player:get_pos()), player)
33 return true, "Armor stand spawned, equipping."