Recreate destroyed translocators...
since mobs doesn't check for protection. Sooo many ways this could go wrong.
This commit is contained in:
parent
419fc2f583
commit
fcee06b6e1
3 changed files with 56 additions and 14 deletions
12
mobs.lua
12
mobs.lua
|
@ -551,7 +551,7 @@ if minetest.registered_entities["mobs_monster:spider"] then
|
|||
end
|
||||
|
||||
fun_caves.climb(self)
|
||||
fun_caves.search_replace(self.object:getpos(), 100, {"air"}, "mobs:cobweb")
|
||||
fun_caves.search_replace(self.object:getpos(), 30, {"air"}, "mobs:cobweb")
|
||||
|
||||
fun_caves.surface_damage(self)
|
||||
end
|
||||
|
@ -593,16 +593,6 @@ if minetest.registered_entities["mobs_monster:spider"] then
|
|||
mobs:register_spawn("fun_caves:tarantula", {"default:desert_sand", "default:dirt_with_dry_grass"}, 99, 0, 3000, 2, 31000)
|
||||
|
||||
mobs:register_egg("fun_caves:tarantula", "Tarantula", "mobs_cobweb.png", 1)
|
||||
|
||||
|
||||
minetest.register_abm({
|
||||
nodenames = {"mobs:cobweb"},
|
||||
interval = 500,
|
||||
chance = 50,
|
||||
action = function(pos, node)
|
||||
minetest.set_node(pos, {name = "air"})
|
||||
end
|
||||
})
|
||||
end
|
||||
|
||||
if minetest.registered_entities["mobs_monster:sand_monster"] then
|
||||
|
|
|
@ -64,7 +64,7 @@ local pyramid_noise_1 = {offset = 0, scale = 1, seed = -6012, spread = {x = 20,
|
|||
|
||||
|
||||
fun_caves.pyramid = function(minp, maxp, data, p2data, area, biomemap, biome_ids, node, heightmap)
|
||||
if math.random(10) ~= 1 then
|
||||
if math.random(20) ~= 1 then
|
||||
return
|
||||
end
|
||||
|
||||
|
|
|
@ -314,6 +314,7 @@ minetest.register_craft({
|
|||
local function translocate(pos, node, clicker, itemstack, pointed_thing)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local id = meta:get_string('id')
|
||||
local owner = meta:get_string('owner')
|
||||
if not (id and tonumber(id)) then
|
||||
return
|
||||
end
|
||||
|
@ -325,9 +326,33 @@ local function translocate(pos, node, clicker, itemstack, pointed_thing)
|
|||
|
||||
local pos2
|
||||
if minetest.serialize(pair[2]) == minetest.serialize(pos) then
|
||||
clicker:setpos(pair[1])
|
||||
pos2 = pair[1]
|
||||
else
|
||||
clicker:setpos(pair[2])
|
||||
pos2 = pair[2]
|
||||
end
|
||||
|
||||
if pos2 then
|
||||
clicker:setpos(pos2)
|
||||
|
||||
-- If the mated translocator doesn't exist, recreate it.
|
||||
minetest.after(1, function()
|
||||
if not owner then
|
||||
return
|
||||
end
|
||||
|
||||
-- If we can't get the node, we can't set it.
|
||||
local node = minetest.get_node_or_nil(pos2)
|
||||
if not node or node.name == 'fun_caves:translocator' then
|
||||
return
|
||||
end
|
||||
|
||||
minetest.set_node(pos2, {name = 'fun_caves:translocator'})
|
||||
local meta = minetest.get_meta(pos2)
|
||||
meta:set_string('id', id)
|
||||
meta:set_string('owner', owner)
|
||||
|
||||
print('Fun Caves: recreated a missing translocator')
|
||||
end)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -426,6 +451,32 @@ local function trans_dig(pos, node, digger)
|
|||
end
|
||||
end
|
||||
|
||||
local function trans_dest(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local id = meta:get_string('id')
|
||||
local owner = meta:get_string('owner')
|
||||
if not (id and owner) then
|
||||
return
|
||||
end
|
||||
|
||||
if not fun_caves.db.translocators[tonumber(id)] then
|
||||
return
|
||||
end
|
||||
local pair = table.copy(fun_caves.db.translocators[tonumber(id)])
|
||||
|
||||
minetest.after(1, function()
|
||||
if not fun_caves.db.translocators[tonumber(id)] or #fun_caves.db.translocators[tonumber(id)] < #pair then
|
||||
return
|
||||
end
|
||||
minetest.set_node(pos, {name = 'fun_caves:translocator'})
|
||||
local meta = minetest.get_meta(pos)
|
||||
meta:set_string('id', id)
|
||||
meta:set_string('owner', owner)
|
||||
|
||||
print('Fun Caves: recreated a destroyed translocator')
|
||||
end)
|
||||
end
|
||||
|
||||
minetest.register_node("fun_caves:translocator", {
|
||||
visual = 'mesh',
|
||||
mesh = "fun_caves_translocator.obj",
|
||||
|
@ -449,6 +500,7 @@ minetest.register_node("fun_caves:translocator", {
|
|||
on_use = trans_use,
|
||||
on_place = trans_place,
|
||||
on_dig = trans_dig,
|
||||
on_destruct = trans_dest,
|
||||
})
|
||||
|
||||
for _, gem in pairs(gems) do
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue