From 5b1be3e6eefa2b4b29e9aa00bc7eb506f8c5daad Mon Sep 17 00:00:00 2001 From: LeMagnesium Date: Sat, 1 Nov 2014 17:21:26 +0100 Subject: [PATCH] Adding beginners_chest mod - A chest for the new players, with some stuff in it, reloaded every 2 hours --- mods/beginners_chest/depends.txt | 2 ++ mods/beginners_chest/init.lua | 35 ++++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+) create mode 100644 mods/beginners_chest/depends.txt create mode 100644 mods/beginners_chest/init.lua diff --git a/mods/beginners_chest/depends.txt b/mods/beginners_chest/depends.txt new file mode 100644 index 00000000..585cc7aa --- /dev/null +++ b/mods/beginners_chest/depends.txt @@ -0,0 +1,2 @@ +default +3d_armor diff --git a/mods/beginners_chest/init.lua b/mods/beginners_chest/init.lua new file mode 100644 index 00000000..f317c97b --- /dev/null +++ b/mods/beginners_chest/init.lua @@ -0,0 +1,35 @@ +--[[ + Beginners_chest mod + Put some useful stuff in a chest for the new players + + Mod ßý Mg, based on an idea of MinetestForFun/Darcidride +]]-- + +chest_position = {x = 5, y = 40, z = -1} +local interval_timer = 0 +local interval_max = 10 + + +minetest.register_globalstep(function(dtime) + interval_timer = interval_timer+dtime + if interval_timer < interval_max then return end -- We have to wait 2 hours + + local chest = minetest.get_node(chest_position) + if chest.name ~= "default:chest" then + if chest.name == "ignore" then + print("[b_chest] Unable to reload chest : area not loaded") + return + elseif chest.name ~= "air" then + print("[b_chest] Unable to place chest : position still used") + return + elseif chest.name == "air" then + minetest.add_node(chest_position,{name = "default:chest"}) + print("[b_chest] Chest placed") + end + end + + local meta = minetest.get_meta(chest_position) + local inv = meta:get_inventory() + inv:set_list("main",{[1] = "3d_armor:boots_steel", [2] = "default:pick_stone", [3] = "default:pick_steel", [32] = ""}) + interval_timer = 0 +end)