mirror of
https://github.com/sys4-fr/server-nalc.git
synced 2025-02-27 16:20:20 +01:00
update tsm_pyramids, add new chest with timer to refill and remove file to save chest pos used to refill
add abm to replace old chest add maptools in depends.txt fix indentations
This commit is contained in:
parent
d1a7ed5ee6
commit
c9b5199e97
@ -1,5 +1,6 @@
|
|||||||
default
|
default
|
||||||
mobs
|
mobs
|
||||||
|
maptools
|
||||||
farming?
|
farming?
|
||||||
treasurer?
|
treasurer?
|
||||||
watershed?
|
watershed?
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
pyramids = {}
|
pyramids = {}
|
||||||
|
pyramids.max_time = 30*60
|
||||||
|
|
||||||
dofile(minetest.get_modpath("tsm_pyramids").."/mummy.lua")
|
dofile(minetest.get_modpath("tsm_pyramids").."/mummy.lua")
|
||||||
dofile(minetest.get_modpath("tsm_pyramids").."/nodes.lua")
|
dofile(minetest.get_modpath("tsm_pyramids").."/nodes.lua")
|
||||||
@ -16,9 +17,8 @@ local chest_stuff = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function pyramids.fill_chest(pos)
|
function pyramids.fill_chest(pos)
|
||||||
minetest.after(2, function()
|
local n = minetest.get_node_or_nil(pos)
|
||||||
local n = minetest.get_node(pos)
|
if n and n.name and n.name == "tsm_pyramids:chest" then
|
||||||
if n and n.name and n.name == "maptools:chest" then
|
|
||||||
local meta = minetest.get_meta(pos)
|
local meta = minetest.get_meta(pos)
|
||||||
local inv = meta:get_inventory()
|
local inv = meta:get_inventory()
|
||||||
inv:set_size("main", 8*4)
|
inv:set_size("main", 8*4)
|
||||||
@ -44,9 +44,7 @@ function pyramids.fill_chest(pos)
|
|||||||
inv:set_stack("main", math.random(1,32), stacks[s])
|
inv:set_stack("main", math.random(1,32), stacks[s])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
end)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
local function add_spawner(pos)
|
local function add_spawner(pos)
|
||||||
@ -73,7 +71,7 @@ local function underground(pos)
|
|||||||
while can_replace(p2)==true do
|
while can_replace(p2)==true do
|
||||||
cnt = cnt+1
|
cnt = cnt+1
|
||||||
if cnt > 25 then break end
|
if cnt > 25 then break end
|
||||||
if cnt>math.random(2,4) then mat = "desert_stone"end
|
if cnt>math.random(2,4) then mat = "desert_stone" end
|
||||||
minetest.set_node(p2, {name="default:"..mat})
|
minetest.set_node(p2, {name="default:"..mat})
|
||||||
p2.y = p2.y-1
|
p2.y = p2.y-1
|
||||||
end
|
end
|
||||||
@ -93,7 +91,7 @@ local function make_entrance(pos)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local function make(pos)
|
function pyramids.make(pos)
|
||||||
minetest.log("action", "Created pyramid at ("..pos.x..","..pos.y..","..pos.z..")")
|
minetest.log("action", "Created pyramid at ("..pos.x..","..pos.y..","..pos.z..")")
|
||||||
for iy=0,10,1 do
|
for iy=0,10,1 do
|
||||||
for ix=iy,22-iy,1 do
|
for ix=iy,22-iy,1 do
|
||||||
@ -124,6 +122,7 @@ local function hlp_fnct(pos, name)
|
|||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local function ground(pos, old)
|
local function ground(pos, old)
|
||||||
local p2 = pos
|
local p2 = pos
|
||||||
while hlp_fnct(p2, "air") do
|
while hlp_fnct(p2, "air") do
|
||||||
@ -177,11 +176,12 @@ minetest.register_on_generated(function(minp, maxp, seed)
|
|||||||
end
|
end
|
||||||
p2.y = p2.y - 3
|
p2.y = p2.y - 3
|
||||||
if p2.y < 0 then p2.y = 0 end
|
if p2.y < 0 then p2.y = 0 end
|
||||||
if minetest.find_node_near(p2, 25, {"default:water_source"}) ~= nil or minetest.find_node_near(p2, 22, {"default:dirt_with_grass"}) ~= nil or minetest.find_node_near(p2, 52, {"maptools:sandstone_brick"}) ~= nil then return end
|
if minetest.find_node_near(p2, 25, {"default:water_source"}) ~= nil
|
||||||
|
or minetest.find_node_near(p2, 22, {"default:dirt_with_grass"}) ~= nil
|
||||||
|
or minetest.find_node_near(p2, 52, {"maptools:sandstone_brick"}) ~= nil then return end
|
||||||
|
|
||||||
if math.random(0,10) > 7 then return end
|
if math.random(0,10) > 7 then return end
|
||||||
make(p2)
|
pyramids.make(p2)
|
||||||
end
|
end
|
||||||
|
|
||||||
end, minp, maxp, seed)
|
end, minp, maxp, seed)
|
||||||
end)
|
end)
|
||||||
|
@ -56,6 +56,27 @@ mobs:register_mob("tsm_pyramids:mummy", {
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
|
--MFF ABM to replace old maptools:chest
|
||||||
|
minetest.register_abm({
|
||||||
|
nodenames = {"tsm_pyramids:spawner_mummy"},
|
||||||
|
interval = 10.0,
|
||||||
|
chance = 1,
|
||||||
|
action = function(pos, node, active_object_count, active_object_count_wider)
|
||||||
|
local chests = minetest.find_nodes_in_area(
|
||||||
|
{x=pos.x-4, y=pos.y-3, z=pos.z-10},
|
||||||
|
{x=pos.x+4, y=pos.y, z=pos.z},
|
||||||
|
"maptools:chest"
|
||||||
|
)
|
||||||
|
for _, cpos in ipairs(chests) do
|
||||||
|
local p2 = 0
|
||||||
|
local n = minetest.get_node_or_nil(cpos)
|
||||||
|
if n and n.param2 then
|
||||||
|
p2 = n.param2
|
||||||
|
end
|
||||||
|
minetest.set_node(cpos, {name="tsm_pyramids:chest", param2=p2})
|
||||||
|
end
|
||||||
|
end
|
||||||
|
})
|
||||||
-- spawner (spawn in pyramids, near the spawner)
|
-- spawner (spawn in pyramids, near the spawner)
|
||||||
if not minetest.setting_getbool("only_peaceful_mobs") then
|
if not minetest.setting_getbool("only_peaceful_mobs") then
|
||||||
minetest.register_abm({
|
minetest.register_abm({
|
||||||
@ -101,10 +122,10 @@ minetest.register_node("tsm_pyramids:spawner_mummy", {
|
|||||||
drop = "",
|
drop = "",
|
||||||
on_construct = function(pos)
|
on_construct = function(pos)
|
||||||
pos.y = pos.y - 0.28
|
pos.y = pos.y - 0.28
|
||||||
minetest.env:add_entity(pos,"tsm_pyramids:mummy_spawner")
|
minetest.add_entity(pos,"tsm_pyramids:mummy_spawner")
|
||||||
end,
|
end,
|
||||||
on_destruct = function(pos)
|
on_destruct = function(pos)
|
||||||
for _,obj in ipairs(minetest.env:get_objects_inside_radius(pos, 1)) do
|
for _,obj in ipairs(minetest.get_objects_inside_radius(pos, 1)) do
|
||||||
if not obj:is_player() then
|
if not obj:is_player() then
|
||||||
if obj ~= nil and obj:get_luaentity().m_name == "dummy" then
|
if obj ~= nil and obj:get_luaentity().m_name == "dummy" then
|
||||||
obj:remove()
|
obj:remove()
|
||||||
@ -122,7 +143,7 @@ minetest.register_craftitem("tsm_pyramids:spawn_egg", {
|
|||||||
stack_max = 99,
|
stack_max = 99,
|
||||||
on_place = function(itemstack, placer, pointed_thing)
|
on_place = function(itemstack, placer, pointed_thing)
|
||||||
if pointed_thing.type == "node" then
|
if pointed_thing.type == "node" then
|
||||||
minetest.env:add_entity(pointed_thing.above,"tsm_pyramids:mummy")
|
minetest.add_entity(pointed_thing.above,"tsm_pyramids:mummy")
|
||||||
if not minetest.setting_getbool("creative_mode") then itemstack:take_item() end
|
if not minetest.setting_getbool("creative_mode") then itemstack:take_item() end
|
||||||
return itemstack
|
return itemstack
|
||||||
end
|
end
|
||||||
|
@ -4,14 +4,14 @@ for i=1,3 do
|
|||||||
minetest.register_node("tsm_pyramids:deco_stone"..i, {
|
minetest.register_node("tsm_pyramids:deco_stone"..i, {
|
||||||
description = "Sandstone with "..img[i],
|
description = "Sandstone with "..img[i],
|
||||||
tiles = {"default_sandstone.png^tsm_pyramids_"..img[i]..".png"},
|
tiles = {"default_sandstone.png^tsm_pyramids_"..img[i]..".png"},
|
||||||
is_ground_content = true,
|
is_ground_content = false,
|
||||||
groups = {unbreakable=1},
|
groups = {unbreakable=1},
|
||||||
sounds = default.node_sound_stone_defaults(),
|
sounds = default.node_sound_stone_defaults(),
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
trap_on_timer = function (pos, elapsed)
|
local trap_on_timer = function (pos, elapsed)
|
||||||
local objs = minetest.env:get_objects_inside_radius(pos, 2)
|
local objs = minetest.get_objects_inside_radius(pos, 2)
|
||||||
for i, obj in pairs(objs) do
|
for i, obj in pairs(objs) do
|
||||||
if obj:is_player() then
|
if obj:is_player() then
|
||||||
local n = minetest.get_node(pos)
|
local n = minetest.get_node(pos)
|
||||||
@ -27,11 +27,11 @@ end
|
|||||||
minetest.register_node("tsm_pyramids:trap", {
|
minetest.register_node("tsm_pyramids:trap", {
|
||||||
description = "Cracked sandstone brick",
|
description = "Cracked sandstone brick",
|
||||||
tiles = {"default_sandstone_brick.png^tsm_pyramids_crack.png"},
|
tiles = {"default_sandstone_brick.png^tsm_pyramids_crack.png"},
|
||||||
is_ground_content = true,
|
is_ground_content = false,
|
||||||
groups = {crumbly=2,cracky=3},
|
groups = {crumbly=2,cracky=3},
|
||||||
sounds = default.node_sound_stone_defaults(),
|
sounds = default.node_sound_stone_defaults(),
|
||||||
on_construct = function(pos)
|
on_construct = function(pos)
|
||||||
minetest.env:get_node_timer(pos):start(0.1)
|
minetest.get_node_timer(pos):start(0.1)
|
||||||
end,
|
end,
|
||||||
crack = 1,
|
crack = 1,
|
||||||
on_timer = trap_on_timer,
|
on_timer = trap_on_timer,
|
||||||
@ -41,8 +41,31 @@ minetest.register_node("tsm_pyramids:trap", {
|
|||||||
minetest.register_node("tsm_pyramids:trap_2", {
|
minetest.register_node("tsm_pyramids:trap_2", {
|
||||||
description = "trapstone",
|
description = "trapstone",
|
||||||
tiles = {"default_sandstone_brick.png^tsm_pyramids_crack.png^[transformR90"},
|
tiles = {"default_sandstone_brick.png^tsm_pyramids_crack.png^[transformR90"},
|
||||||
is_ground_content = true,
|
is_ground_content = false,
|
||||||
groups = {crumbly=2,cracky=3,falling_node=1,not_in_creative_inventory=1},
|
groups = {crumbly=2,cracky=3,falling_node=1,not_in_creative_inventory=1},
|
||||||
sounds = default.node_sound_stone_defaults(),
|
sounds = default.node_sound_stone_defaults(),
|
||||||
drop = "",
|
drop = "",
|
||||||
})
|
})
|
||||||
|
|
||||||
|
local chestdef = minetest.registered_nodes["default:chest"]
|
||||||
|
minetest.register_node("tsm_pyramids:chest",{
|
||||||
|
description = "tsm_pyramids Chest auto refilled",
|
||||||
|
tiles = chestdef.tiles,
|
||||||
|
stack_max = 1000,
|
||||||
|
paramtype2 = "facedir",
|
||||||
|
is_ground_content = false,
|
||||||
|
on_construct = function(pos)
|
||||||
|
chestdef.on_construct(pos)
|
||||||
|
minetest.get_node_timer(pos):start(pyramids.max_time)
|
||||||
|
pyramids.fill_chest(pos)
|
||||||
|
end,
|
||||||
|
on_metadata_inventory_move = chestdef.on_metadata_inventory_move,
|
||||||
|
on_metadata_inventory_put = chestdef.on_metadata_inventory_put,
|
||||||
|
on_metadata_inventory_take = chestdef.on_metadata_inventory_take,
|
||||||
|
groups = {unbreakable = 1, not_in_creative_inventory = 1},
|
||||||
|
on_timer = function (pos, elapsed)
|
||||||
|
pyramids.fill_chest(pos)
|
||||||
|
return true
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
|
||||||
|
@ -1,6 +1,3 @@
|
|||||||
pyramids.saved_chests = {}
|
|
||||||
pyramids.max_time = 30*60
|
|
||||||
|
|
||||||
|
|
||||||
local room = {"a","a","a","a","a","a","a","a","a",
|
local room = {"a","a","a","a","a","a","a","a","a",
|
||||||
"a","c","a","c","a","c","a","c","a",
|
"a","c","a","c","a","c","a","c","a",
|
||||||
@ -33,56 +30,14 @@ code["a"] = "air"
|
|||||||
code["l"] = "lava_source"
|
code["l"] = "lava_source"
|
||||||
code["t"] = "trap"
|
code["t"] = "trap"
|
||||||
|
|
||||||
function loadchests()
|
|
||||||
local file = io.open(minetest.get_worldpath().."/pyramids_chests.txt","r")
|
|
||||||
if file then
|
|
||||||
local saved_chests = minetest.deserialize(file:read())
|
|
||||||
io.close(file)
|
|
||||||
if saved_chests and type(saved_chests) == "table" then
|
|
||||||
minetest.log("action","[tsm_pyramids] Chest loaded")
|
|
||||||
return saved_chests
|
|
||||||
else
|
|
||||||
minetest.log("error","[tsm_pyramids] Loading Chest failed")
|
|
||||||
end
|
|
||||||
end
|
|
||||||
return {}
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
function savechests()
|
|
||||||
local file = io.open(minetest.get_worldpath().."/pyramids_chests.txt","w")
|
|
||||||
if not file then return end -- should not happen
|
|
||||||
file:write(minetest.serialize(pyramids.saved_chests))
|
|
||||||
io.close(file)
|
|
||||||
minetest.log("action","[tsm_pyramids] Chests saved")
|
|
||||||
end
|
|
||||||
|
|
||||||
pyramids.saved_chests = loadchests()
|
|
||||||
minetest.register_on_shutdown(function()
|
|
||||||
savechests()
|
|
||||||
end)
|
|
||||||
|
|
||||||
local function chests_reload()
|
|
||||||
-- It might happen that chests are not loaded
|
|
||||||
if pyramids.saved_chests then
|
|
||||||
for _,k in ipairs(pyramids.saved_chests) do
|
|
||||||
pyramids.fill_chest(k)
|
|
||||||
end
|
|
||||||
else
|
|
||||||
pyramids.saved_chests = loadchests() or {}
|
|
||||||
end
|
|
||||||
minetest.log("action","[tsm_pyramids] Chests reloaded")
|
|
||||||
minetest.after(pyramids.max_time, chests_reload)
|
|
||||||
end
|
|
||||||
minetest.after(0, chests_reload)
|
|
||||||
|
|
||||||
local function replace(str,iy)
|
local function replace(str,iy)
|
||||||
local out = "default:"
|
local out = "default:"
|
||||||
if iy < 4 and str == "c" then str = "a" end
|
if iy < 4 and str == "c" then str = "a" end
|
||||||
if iy == 0 and str == "s" then out = "tsm_pyramids:" str = "sun" end
|
if iy == 0 and str == "s" then out = "tsm_pyramids:" str = "sun" end
|
||||||
if iy == 3 and str == "s" then out = "tsm_pyramids:" str = "men" end
|
if iy == 3 and str == "s" then out = "tsm_pyramids:" str = "men" end
|
||||||
if str == "a" then out = "" end
|
if str == "a" then out = "" end
|
||||||
if str == "c" or str == "s" or str == "b" then out = "maptools:" end
|
if str == "c" then out = "tsm_pyramids:" end --MFF newchest
|
||||||
|
if str == "s" or str == "b" then out = "maptools:" end
|
||||||
return out..code[str]
|
return out..code[str]
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -104,13 +59,8 @@ function pyramids.make_room(pos)
|
|||||||
local p2 = 0
|
local p2 = 0
|
||||||
if n_str == "c" then
|
if n_str == "c" then
|
||||||
if ix < 3 then p2 = 1 else p2 = 3 end
|
if ix < 3 then p2 = 1 else p2 = 3 end
|
||||||
pyramids.fill_chest({x=loch.x+ix,y=loch.y-iy,z=loch.z+iz})
|
|
||||||
end
|
|
||||||
local node_name = replace(n_str,iy)
|
|
||||||
minetest.set_node({x=loch.x+ix,y=loch.y-iy,z=loch.z+iz}, {name=node_name, param2=p2})
|
|
||||||
if node_name == "maptools:chest" then
|
|
||||||
table.insert(pyramids.saved_chests,1,{x=loch.x+ix,y=loch.y-iy,z=loch.z+iz})
|
|
||||||
end
|
end
|
||||||
|
minetest.set_node({x=loch.x+ix,y=loch.y-iy,z=loch.z+iz}, {name=replace(n_str,iy), param2=p2})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user