1
0
mirror of https://github.com/sys4-fr/server-nalc.git synced 2025-01-11 18:40:25 +01:00

Upgrading beginners_chest

- Beginners_chest is now at version 1.1, you can use multiple chests
This commit is contained in:
LeMagnesium 2014-11-09 15:48:50 +01:00
parent fde68fad64
commit 1249a48176

View File

@ -1,36 +1,71 @@
--[[ --[[
Beginners_chest mod Beginners_chest mod
Put some useful stuff in a chest for the new players Put some useful stuff in chests for the new players
Version : 1.1 - 11/8/2014_14h48UTC
Last modification by Mg on the : 11/8/2014 @ 14h48 UTC
Mod ßý Mg, based on an idea of MinetestForFun/Darcidride Mod ßý Mg, based on an idea of MinetestForFun/Darcidride
]]-- ]]--
chest_position = {x = 5, y = 40, z = -1} chests = {
local interval_timer = 0 [1] = {
local interval_max = 7200 position = {x = 5, y = 40, z = -1},
interval_timer = 0,
interval_max = 7200,
stuff = {
[1] = "3d_armor:boots_steel",
[2] = "default:pick_stone",
[3] = "default:sword_stone",
[32] = ""
}
}
}
minetest.register_globalstep(function(dtime) minetest.register_globalstep(function(dtime)
interval_timer = interval_timer+dtime local i = 1
--print(interval_timer) while i < table.getn(chests)+1 do
if interval_timer < interval_max then return end -- We have to wait
interval_timer = 0 if not chests[i].stuff then
local chest = minetest.get_node(chest_position) chests[i].stuff = {
if chest.name ~= "default:chest" then [1] = "default:wood",
if chest.name == "ignore" then [32] = ""
minetest.log("action","[b_chest] Unable to reload chest : area not loaded") -- c'est cool mais ça fait une boucle et un debug.txt de 40Mo }
return end
elseif chest.name ~= "air" then if not chests[i].interval_timer then
minetest.log("action","[b_chest] Unable to place chest : position still used") -- c'est cool mais ça fait une boucle et un debug.txt de 40Mo chests[i].interval_timer = 0
return end
elseif chest.name == "air" then if not chests[i].interval_max then
minetest.add_node(chest_position,{name = "default:chest"}) chests[i].interval_max = 7200 -- Using default value : 2h
minetest.log("action","[b_chest] Chest placed") end
chests[i].interval_timer = chests[i].interval_timer + dtime
if chests[i].position.x and chests[i].position.y and chests[i].position.z and chests[i].interval_timer >= chests[i].interval_max then
chests[i].interval_timer = 0
node = minetest.get_node(chests[i].position)
if node.name ~= "ignore" then
if node.name ~= "default:chest" then
if node.name == "air" then
minetest.add_node(chests[i].position,{name = "default:chest"})
minetest.log("action","[b_chest]["..i.."] Chest placed at "..chests[i].position.x..", "..chests[i].position.y..", "..chests[i].position.z)
else
minetest.log("action","[b_chest]["..i.."] Unable to place chest at "..chests[i].position.x..", "..chests[i].position.y..", "..chests[i].position.z.." : place already in use.")
break
end end
end end
local meta = minetest.get_meta(chest_position) meta = minetest.get_meta(chests[i].position)
local inv = meta:get_inventory() inv = meta:get_inventory()
inv:set_list("main",{[1] = "3d_armor:boots_steel", [2] = "default:pick_stone", [3] = "default:sword_stone", [32] = ""}) inv:set_list("main", chests[i].stuff)
minetest.log("action","[b_chest]["..i.."] Chest reloaded at "..chests[i].position.x..", "..chests[i].position.y..", "..chests[i].position.z)
else
minetest.log("action","[b_chest]["..i.."] Cannot reload chest at "..chests[i].position.x..", "..chests[i].position.y..", "..chests[i].position.z.." : area not loaded.")
end
end
i = i + 1
end
end) end)