initial commit - create a modpack
1
.gitignore
vendored
@ -1 +1,2 @@
|
||||
settings.txt
|
||||
config.lua
|
||||
|
241
config.example.lua
Normal file
@ -0,0 +1,241 @@
|
||||
-- * [name : string] - Name of the mob used in the mod.
|
||||
|
||||
-- [egg_name_custom : string] - Custom name for the egg item. If empty default name will be used i.e. 'mobs:chicken'.
|
||||
|
||||
-- * [dummy_size : table] - Size of the rotating dummy inside the node.
|
||||
|
||||
-- * [dummy_offset : integer] - Offset on Y axis of the dummy inside the node.
|
||||
|
||||
-- * [dummy_mesh : string] - Filename of the model used fot he mob.
|
||||
|
||||
-- * [dummy_texture : table] - Textures used for the mob.
|
||||
|
||||
-- * [night_only : boolean : string] - If true mobs will spawn only during the night or in dark areas, default:true. Writing "disable" will disable light check and it will spawn in both states (night and day)
|
||||
|
||||
-- [sound_custom : string] - Custom name for the sound file name if differ from default: i.e 'mobs_cow'.
|
||||
|
||||
-- [env : boolean] - This spawner will become environmental spawner. Environmental spawners have different properties/behaviour (used for map gen) and cannot be crafted.
|
||||
|
||||
-- [*] -> MANDATORY - has to be filled in!
|
||||
|
||||
-- mods what should be enabled and loded, remove/add the one you want to load
|
||||
ENABLED_MODS = {"mobs", "pyramids", "creatures"}
|
||||
|
||||
-- mobs properties - setup all you mobs here
|
||||
MOBS_PROPS = {
|
||||
|
||||
["mobs"] = { -- MOBS REDO CONFIG
|
||||
{
|
||||
name="sheep_white",
|
||||
egg_name_custom="",
|
||||
dummy_size={x=0.52,y=0.52},
|
||||
dummy_offset=0.2,
|
||||
dummy_mesh="mobs_sheep.b3d",
|
||||
dummy_texture={"mobs_sheep_wool.png^mobs_sheep_base.png"},
|
||||
night_only=false,
|
||||
sound_custom="mobs_sheep"
|
||||
},
|
||||
{
|
||||
name="cow",
|
||||
egg_name_custom="",
|
||||
dummy_size={x=0.3,y=0.3},
|
||||
dummy_offset=-0.3,
|
||||
dummy_mesh="mobs_cow.x",
|
||||
dummy_texture={"mobs_cow.png"},
|
||||
night_only=false,
|
||||
sound_custom=""
|
||||
},
|
||||
{
|
||||
name="chicken",
|
||||
egg_name_custom="",
|
||||
dummy_size={x=0.9,y=0.9},
|
||||
dummy_offset=0.2,
|
||||
dummy_mesh="mobs_chicken.x",
|
||||
dummy_texture={"mobs_chicken.png", "mobs_chicken.png", "mobs_chicken.png", "mobs_chicken.png", "mobs_chicken.png", "mobs_chicken.png", "mobs_chicken.png", "mobs_chicken.png", "mobs_chicken.png"},
|
||||
night_only=false,
|
||||
sound_custom=""
|
||||
},
|
||||
{
|
||||
name="pumba",
|
||||
egg_name_custom="",
|
||||
dummy_size={x=0.62,y=0.62},
|
||||
dummy_offset=-0.3,
|
||||
dummy_mesh="mobs_pumba.x",
|
||||
dummy_texture={"mobs_pumba.png"},
|
||||
night_only=false,
|
||||
sound_custom="mobs_pig"
|
||||
},
|
||||
{
|
||||
name="bunny",
|
||||
egg_name_custom="",
|
||||
dummy_size={x=1,y=1},
|
||||
dummy_offset=0.2,
|
||||
dummy_mesh="mobs_bunny.b3d",
|
||||
dummy_texture={"mobs_bunny_brown.png"},
|
||||
night_only=false,
|
||||
sound_custom="spawners_bunny"
|
||||
},
|
||||
{
|
||||
name="kitten",
|
||||
egg_name_custom="",
|
||||
dummy_size={x=0.32,y=0.32},
|
||||
dummy_offset=0,
|
||||
dummy_mesh="mobs_kitten.b3d",
|
||||
dummy_texture={"mobs_kitten_ginger.png"},
|
||||
night_only=false,
|
||||
sound_custom=""
|
||||
},
|
||||
{
|
||||
name="spider",
|
||||
egg_name_custom="",
|
||||
dummy_size={x=2,y=2},
|
||||
dummy_offset=-0.2,
|
||||
dummy_mesh="mobs_spider.x",
|
||||
dummy_texture={"mobs_spider.png"},
|
||||
night_only=false,
|
||||
sound_custom=""
|
||||
},
|
||||
{
|
||||
name="spider",
|
||||
egg_name_custom="",
|
||||
dummy_size={x=2,y=2},
|
||||
dummy_offset=-0.2,
|
||||
dummy_mesh="mobs_spider.x",
|
||||
dummy_texture={"mobs_spider.png"},
|
||||
night_only="disable",
|
||||
sound_custom="",
|
||||
env = true
|
||||
},
|
||||
{
|
||||
name="stone_monster",
|
||||
egg_name_custom="",
|
||||
dummy_size={x=0.5,y=0.5},
|
||||
dummy_offset=0.05,
|
||||
dummy_mesh="mobs_stone_monster.b3d",
|
||||
dummy_texture={"mobs_stone_monster.png"},
|
||||
night_only=false,
|
||||
sound_custom="mobs_stonemonster"
|
||||
},
|
||||
{
|
||||
name="oerkki",
|
||||
egg_name_custom="",
|
||||
dummy_size={x=0.5,y=0.5},
|
||||
dummy_offset=0.05,
|
||||
dummy_mesh="mobs_oerkki.b3d",
|
||||
dummy_texture={"mobs_oerkki.png"},
|
||||
night_only=true,
|
||||
sound_custom=""
|
||||
},
|
||||
{
|
||||
name="tree_monster",
|
||||
egg_name_custom="",
|
||||
dummy_size={x=0.4,y=0.4},
|
||||
dummy_offset=0.05,
|
||||
dummy_mesh="mobs_tree_monster.b3d",
|
||||
dummy_texture={"mobs_tree_monster.png"},
|
||||
night_only=true,
|
||||
sound_custom="mobs_treemonster"
|
||||
}
|
||||
},
|
||||
|
||||
["pyramids"] = { -- PYRAMIDS MOD CONFIG
|
||||
{
|
||||
name="mummy",
|
||||
egg_name_custom="pyramids:spawn_egg",
|
||||
dummy_size={x=3.3,y=3.3},
|
||||
dummy_offset=-0.3,
|
||||
dummy_mesh="pyramids_mummy.x",
|
||||
dummy_texture={"pyramids_mummy.png"},
|
||||
night_only=false,
|
||||
sound_custom="mummy"
|
||||
}
|
||||
},
|
||||
|
||||
["creatures"] = { -- CREATURES MOD CONFIG
|
||||
{
|
||||
name="chicken",
|
||||
egg_name_custom="creatures:chicken_spawn_egg",
|
||||
dummy_size={x=0.9,y=0.9},
|
||||
dummy_offset=-0.3,
|
||||
dummy_mesh="creatures_chicken.b3d",
|
||||
dummy_texture={"creatures_chicken.png"},
|
||||
night_only=false,
|
||||
sound_custom=""
|
||||
},
|
||||
{
|
||||
name="ghost",
|
||||
egg_name_custom="creatures:ghost_spawn_egg",
|
||||
dummy_size={x=0.7,y=0.7},
|
||||
dummy_offset=-0.5,
|
||||
dummy_mesh="creatures_ghost.b3d",
|
||||
dummy_texture={"creatures_ghost.png"},
|
||||
night_only=true,
|
||||
sound_custom=""
|
||||
},
|
||||
{
|
||||
name="sheep",
|
||||
egg_name_custom="creatures:sheep_spawn_egg",
|
||||
dummy_size={x=0.6,y=0.6},
|
||||
dummy_offset=-0.3,
|
||||
dummy_mesh="creatures_sheep.b3d",
|
||||
dummy_texture={"creatures_sheep.png^creatures_sheep_white.png"},
|
||||
night_only=false,
|
||||
sound_custom=""
|
||||
},
|
||||
{
|
||||
name="zombie",
|
||||
egg_name_custom="creatures:zombie_spawn_egg",
|
||||
dummy_size={x=0.5,y=0.5},
|
||||
dummy_offset=-0.5,
|
||||
dummy_mesh="creatures_zombie.b3d",
|
||||
dummy_texture={"creatures_zombie.png"},
|
||||
night_only=false,
|
||||
sound_custom=""
|
||||
},
|
||||
{
|
||||
name="oerrki",
|
||||
egg_name_custom="creatures:oerrki_spawn_egg",
|
||||
dummy_size={x=0.4,y=0.4},
|
||||
dummy_offset=-0.5,
|
||||
dummy_mesh="creatures_oerrki.b3d",
|
||||
dummy_texture={"creatures_oerrki.png"},
|
||||
night_only=false,
|
||||
sound_custom="creatures_oerrki_idle"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
--
|
||||
-- check for 3rd party dependencies
|
||||
--
|
||||
|
||||
-- include mummy mobs redo addon (spawner)
|
||||
if minetest.get_modpath("mobs") ~= nil then
|
||||
-- enable spawner
|
||||
table.insert(ENABLED_MODS, "spawners")
|
||||
|
||||
-- configure spawner
|
||||
MOBS_PROPS["spawners"] = {
|
||||
{
|
||||
name="mummy",
|
||||
egg_name_custom="",
|
||||
dummy_size={x=0.4,y=0.4},
|
||||
dummy_offset=0,
|
||||
dummy_mesh="spawners_mob_mummy.b3d",
|
||||
dummy_texture={"spawners_mob_mummy.png"},
|
||||
night_only="disable",
|
||||
sound_custom="spawners_mob_mummy"
|
||||
},
|
||||
{
|
||||
name="mummy",
|
||||
egg_name_custom="",
|
||||
dummy_size={x=0.4,y=0.4},
|
||||
dummy_offset=0,
|
||||
dummy_mesh="spawners_mob_mummy.b3d",
|
||||
dummy_texture={"spawners_mob_mummy.png"},
|
||||
night_only="disable",
|
||||
sound_custom="spawners_mob_mummy",
|
||||
env=true
|
||||
}
|
||||
}
|
||||
end
|
@ -1,5 +1,3 @@
|
||||
default
|
||||
mobs?
|
||||
creatures?
|
||||
fake_fire?
|
||||
xpanes?
|
||||
|
0
modpack.txt
Normal file
34
spawners_env/chests_gen.lua
Normal file
@ -0,0 +1,34 @@
|
||||
-- Place chests in dungeons and temples
|
||||
local function place_chest(param)
|
||||
local tab = param
|
||||
|
||||
local pos = tab[math.random(1, (#tab or 4))]
|
||||
pos.y = pos.y - 1
|
||||
|
||||
local n = minetest.get_node_or_nil(pos)
|
||||
|
||||
if n and n.name ~= "air" then
|
||||
pos.y = pos.y + 1
|
||||
|
||||
minetest.log("action", "[Mod][Spawners] Chest placed at: "..minetest.pos_to_string(pos))
|
||||
|
||||
minetest.set_node(pos, {name = "default:chest"})
|
||||
|
||||
pyramids.fill_chest(pos)
|
||||
end
|
||||
end
|
||||
|
||||
minetest.set_gen_notify("dungeon")
|
||||
minetest.set_gen_notify("temple")
|
||||
|
||||
minetest.register_on_generated(function(minp, maxp, blockseed)
|
||||
local ntf = minetest.get_mapgen_object("gennotify")
|
||||
|
||||
if ntf and ntf.dungeon then
|
||||
minetest.after(3, place_chest, table.copy(ntf.dungeon))
|
||||
end
|
||||
|
||||
if ntf and ntf.temple then
|
||||
minetest.after(3, place_chest, table.copy(ntf.temple))
|
||||
end
|
||||
end)
|
42
spawners_env/init.lua
Normal file
@ -0,0 +1,42 @@
|
||||
-- Main settings
|
||||
dofile(minetest.get_modpath("spawners").."/settings.txt")
|
||||
|
||||
-- Spawners configurations
|
||||
dofile(minetest.get_modpath("spawners").."/config.lua")
|
||||
|
||||
-- API
|
||||
dofile(minetest.get_modpath("spawners").."/API.lua")
|
||||
|
||||
-- Spawners for mobs
|
||||
dofile(minetest.get_modpath("spawners").."/spawners_mobs.lua")
|
||||
|
||||
-- Spawners for ores
|
||||
dofile(minetest.get_modpath("spawners").."/spawners_ores.lua")
|
||||
|
||||
-- include mummy mobs redo addon (mob)
|
||||
if minetest.get_modpath("mobs") then
|
||||
dofile(minetest.get_modpath("spawners").."/mob_mummy.lua")
|
||||
end
|
||||
|
||||
-- Spawners Pyramids
|
||||
if SPAWN_PYRAMIDS then
|
||||
dofile(minetest.get_modpath("spawners").."/pyramids.lua")
|
||||
|
||||
print("[Mod][spawners] Pyramids enabled")
|
||||
end
|
||||
|
||||
-- Add Spawners to dungeons, temples..
|
||||
if SPAWNERS_GENERATE then
|
||||
dofile(minetest.get_modpath("spawners").."/spawners_gen.lua")
|
||||
|
||||
print("[Mod][spawners] Spawners generate enabled")
|
||||
end
|
||||
|
||||
-- Add Chests to dungeons, temples..
|
||||
if CHESTS_GENERATE then
|
||||
dofile(minetest.get_modpath("spawners").."/chests_gen.lua")
|
||||
|
||||
print("[Mod][spawners] Chests generate enabled")
|
||||
end
|
||||
|
||||
print ("[Mod] Spawners 0.6 Loaded.")
|
260
spawners_env/pyramids.lua
Normal file
@ -0,0 +1,260 @@
|
||||
-- Pyramids by BlockMen
|
||||
|
||||
pyramids = {}
|
||||
|
||||
dofile(minetest.get_modpath("spawners").."/pyramids_nodes.lua")
|
||||
dofile(minetest.get_modpath("spawners").."/pyramids_room.lua")
|
||||
|
||||
local chest_stuff = {
|
||||
{name="default:apple", max = 3},
|
||||
{name="default:torch", max = 10},
|
||||
{name="default:aspen_sapling", max = 5},
|
||||
{name="farming:bread", max = 3},
|
||||
{name="default:steel_ingot", max = 2},
|
||||
{name="default:gold_ingot", max = 2},
|
||||
{name="default:bronze_ingot", max = 2},
|
||||
{name="default:copper_ingot", max = 2},
|
||||
{name="default:diamond", max = 1},
|
||||
{name="default:pick_steel", max = 1},
|
||||
{name="default:pick_diamond", max = 1},
|
||||
{name="default:pick_bronze", max = 1},
|
||||
{name="default:pick_mese", max = 1},
|
||||
{name="default:pick_stone", max = 1},
|
||||
{name="default:pick_wood", max = 1},
|
||||
{name="default:sword_bronze", max = 1},
|
||||
{name="default:sword_diamond", max = 1},
|
||||
{name="default:sword_mese", max = 1},
|
||||
{name="default:sword_steel", max = 1},
|
||||
{name="default:sword_stone", max = 1},
|
||||
{name="default:sword_wood", max = 1},
|
||||
{name="default:shovel_bronze", max = 1},
|
||||
{name="default:shovel_diamond", max = 1},
|
||||
{name="default:shovel_mese", max = 1},
|
||||
{name="default:shovel_steel", max = 1},
|
||||
{name="default:shovel_stone", max = 1},
|
||||
{name="default:shovel_wood", max = 1},
|
||||
{name="default:axe_bronze", max = 1},
|
||||
{name="default:axe_diamond", max = 1},
|
||||
{name="default:axe_mese", max = 1},
|
||||
{name="default:axe_steel", max = 1},
|
||||
{name="default:axe_stone", max = 1},
|
||||
{name="default:axe_wood", max = 1},
|
||||
{name="diamonds:diamond_apple", max = 1},
|
||||
}
|
||||
|
||||
function pyramids.fill_chest(pos)
|
||||
minetest.after(2, function()
|
||||
local n = minetest.get_node(pos)
|
||||
|
||||
if n and n.name and n.name == "default:chest" then
|
||||
local meta = minetest.get_meta(pos)
|
||||
local inv = meta:get_inventory()
|
||||
|
||||
inv:set_size("main", 8*4)
|
||||
|
||||
-- if math.random(1,10) < 5 then return end
|
||||
|
||||
for i=0,2,1 do
|
||||
local stuff = chest_stuff[math.random(1,#chest_stuff)]
|
||||
|
||||
if stuff.name == "farming:bread" and not minetest.get_modpath("farming") then
|
||||
stuff = chest_stuff[1]
|
||||
end
|
||||
|
||||
if stuff.name == "diamonds:diamond_apple" and not minetest.get_modpath("diamonds") then
|
||||
stuff = chest_stuff[1]
|
||||
end
|
||||
|
||||
local stack = {name=stuff.name, count = math.random(1,stuff.max)}
|
||||
|
||||
if not inv:contains_item("main", stack) then
|
||||
inv:set_stack("main", math.random(1,32), stack)
|
||||
end
|
||||
end
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
function pyramids.spawn_mummy(pos, number)
|
||||
-- needs mobs redo
|
||||
if minetest.get_modpath("mobs") ~= nil then
|
||||
for i=0,number do
|
||||
minetest.add_entity(pos,"spawners:mummy")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function add_spawner(pos)
|
||||
-- needs mobs redo
|
||||
if minetest.get_modpath("mobs") ~= nil then
|
||||
minetest.set_node(pos, {name="spawners:spawners_mummy_spawner_env"})
|
||||
|
||||
if not minetest.setting_getbool("only_peaceful_mobs") then pyramids.spawn_mummy({x=pos.x,y=pos.y,z=pos.z-2},2)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function can_replace(pos)
|
||||
local n = minetest.get_node_or_nil(pos)
|
||||
if n and n.name and minetest.registered_nodes[n.name] and not minetest.registered_nodes[n.name].walkable then
|
||||
return true
|
||||
elseif not n then
|
||||
return true
|
||||
else
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
local function underground(pos)
|
||||
local p2 = pos
|
||||
local cnt = 0
|
||||
local mat = "desert_sand"
|
||||
p2.y = p2.y-1
|
||||
while can_replace(p2)==true do
|
||||
cnt = cnt+1
|
||||
if cnt > 25 then break end
|
||||
if cnt>math.random(2,4) then mat = "desert_stone"end
|
||||
minetest.set_node(p2, {name="default:"..mat})
|
||||
p2.y = p2.y-1
|
||||
end
|
||||
end
|
||||
|
||||
local function make_entrance(pos)
|
||||
local gang = {x=pos.x+10,y=pos.y, z=pos.z}
|
||||
for iy=2,3,1 do
|
||||
for iz=0,6,1 do
|
||||
minetest.remove_node({x=gang.x+1,y=gang.y+iy,z=gang.z+iz})
|
||||
if iz >=3 and iy == 3 then
|
||||
minetest.set_node({x=gang.x,y=gang.y+iy+1,z=gang.z+iz}, {name="default:sandstonebrick"})
|
||||
minetest.set_node({x=gang.x+1,y=gang.y+iy+1,z=gang.z+iz}, {name="default:sandstonebrick"})
|
||||
minetest.set_node({x=gang.x+2,y=gang.y+iy+1,z=gang.z+iz}, {name="default:sandstonebrick"})
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function make(pos)
|
||||
minetest.log("action", "Created pyramid at ("..pos.x..","..pos.y..","..pos.z..")")
|
||||
for iy=0,10,1 do
|
||||
for ix=iy,22-iy,1 do
|
||||
for iz=iy,22-iy,1 do
|
||||
if iy <1 then underground({x=pos.x+ix,y=pos.y,z=pos.z+iz}) end
|
||||
minetest.set_node({x=pos.x+ix,y=pos.y+iy,z=pos.z+iz}, {name="default:sandstonebrick"})
|
||||
for yy=1,10-iy,1 do
|
||||
local n = minetest.get_node({x=pos.x+ix,y=pos.y+iy+yy,z=pos.z+iz})
|
||||
if n and n.name and n.name == "default:desert_stone" then minetest.set_node({x=pos.x+ix,y=pos.y+iy+yy,z=pos.z+iz},{name="default:desert_sand"}) end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
pyramids.make_room(pos)
|
||||
minetest.after(2, pyramids.make_traps, pos)
|
||||
|
||||
-- needs mobs redo
|
||||
if minetest.get_modpath("mobs") ~= nil then
|
||||
add_spawner({x=pos.x+11,y=pos.y+2, z=pos.z+16})
|
||||
end
|
||||
|
||||
make_entrance({x=pos.x,y=pos.y, z=pos.z})
|
||||
end
|
||||
|
||||
local perl1 = {SEED1 = 9130, OCTA1 = 3, PERS1 = 0.5, SCAL1 = 250} -- Values should match minetest mapgen V6 desert noise
|
||||
|
||||
if minetest.get_modpath("simplev7") ~= nil then
|
||||
perl1 = {SEED1 = 5349, OCTA1 = 3, PERS1 = 0.7, SCAL1 = 500}
|
||||
end
|
||||
|
||||
local function hlp_fnct(pos, name)
|
||||
local n = minetest.get_node_or_nil(pos)
|
||||
if n and n.name and n.name == name then
|
||||
return true
|
||||
else
|
||||
return false
|
||||
end
|
||||
end
|
||||
local function ground(pos, old)
|
||||
local p2 = pos
|
||||
while hlp_fnct(p2, "air") do
|
||||
p2.y = p2.y -1
|
||||
end
|
||||
if p2.y < old.y then
|
||||
return p2
|
||||
else
|
||||
return old
|
||||
end
|
||||
end
|
||||
|
||||
minetest.register_on_generated(function(minp, maxp, seed)
|
||||
if maxp.y < 0 then return end
|
||||
math.randomseed(seed)
|
||||
local cnt = 0
|
||||
|
||||
local perlin1 = minetest.get_perlin(perl1.SEED1, perl1.OCTA1, perl1.PERS1, perl1.SCAL1)
|
||||
local noise1 = perlin1:get2d({x=minp.x,y=minp.y})--,z=minp.z})
|
||||
|
||||
if noise1 > 0.25 or noise1 < -0.26 then
|
||||
local mpos = {x=math.random(minp.x,maxp.x), y=math.random(minp.y,maxp.y), z=math.random(minp.z,maxp.z)}
|
||||
|
||||
local p2 = minetest.find_node_near(mpos, 25, {"default:desert_sand"})
|
||||
while p2 == nil and cnt < 5 do
|
||||
cnt = cnt+1
|
||||
mpos = {x=math.random(minp.x,maxp.x), y=math.random(minp.y,maxp.y), z=math.random(minp.z,maxp.z)}
|
||||
p2 = minetest.find_node_near(mpos, 25, {"default:desert_sand"})
|
||||
end
|
||||
if p2 == nil then return end
|
||||
if p2.y < 0 then return end
|
||||
|
||||
local off = 0
|
||||
local opos1 = {x=p2.x+22,y=p2.y-1,z=p2.z+22}
|
||||
local opos2 = {x=p2.x+22,y=p2.y-1,z=p2.z}
|
||||
local opos3 = {x=p2.x,y=p2.y-1,z=p2.z+22}
|
||||
local opos1_n = minetest.get_node_or_nil(opos1)
|
||||
local opos2_n = minetest.get_node_or_nil(opos2)
|
||||
local opos3_n = minetest.get_node_or_nil(opos3)
|
||||
if opos1_n and opos1_n.name and opos1_n.name == "air" then
|
||||
p2 = ground(opos1, p2)
|
||||
end
|
||||
if opos2_n and opos2_n.name and opos2_n.name == "air" then
|
||||
p2 = ground(opos2, p2)
|
||||
end
|
||||
if opos3_n and opos3_n.name and opos3_n.name == "air" then
|
||||
p2 = ground(opos3, p2)
|
||||
end
|
||||
p2.y = p2.y - 3
|
||||
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, {"default:sandstonebrick"}) ~= nil then return end
|
||||
|
||||
if math.random(0,10) > 7 then return end
|
||||
minetest.after(0.8,make,p2)
|
||||
end
|
||||
end)
|
||||
|
||||
--
|
||||
-- backwards compatibility
|
||||
--
|
||||
|
||||
-- spawner mummy
|
||||
minetest.register_alias("pyramids:spawner_mummy", "spawners:spawners_mummy_spawner_env")
|
||||
-- minetest.register_alias("pyramids:mummy_spawner", "spawners:spawners_mummy_spawner_env")
|
||||
|
||||
-- spawn egg
|
||||
minetest.register_alias("pyramids:spawn_egg", "spawners:mummy")
|
||||
|
||||
-- mummy entity
|
||||
minetest.register_alias("pyramids:mummy", "spawners:mummy")
|
||||
|
||||
-- deco stone 1
|
||||
minetest.register_alias("pyramids:deco_stone1", "spawners:deco_stone1")
|
||||
|
||||
-- deco stone 2
|
||||
minetest.register_alias("pyramids:deco_stone2", "spawners:deco_stone2")
|
||||
|
||||
-- deco stone 3
|
||||
minetest.register_alias("pyramids:deco_stone3", "spawners:deco_stone3")
|
||||
|
||||
-- deco trap
|
||||
minetest.register_alias("pyramids:trap", "spawners:trap")
|
||||
|
||||
-- deco trap 2
|
||||
minetest.register_alias("pyramids:trap_2", "spawners:trap_2")
|
50
spawners_env/pyramids_nodes.lua
Normal file
@ -0,0 +1,50 @@
|
||||
local img = {"eye", "men", "sun"}
|
||||
|
||||
for i=1,3 do
|
||||
minetest.register_node("spawners:deco_stone"..i, {
|
||||
description = "Sandstone with "..img[i],
|
||||
tiles = {"default_sandstone.png^pyramids_"..img[i]..".png"},
|
||||
is_ground_content = true,
|
||||
groups = {crumbly=2,cracky=3},
|
||||
sounds = default.node_sound_stone_defaults(),
|
||||
})
|
||||
end
|
||||
|
||||
trap_on_timer = function (pos, elapsed)
|
||||
local objs = minetest.get_objects_inside_radius(pos, 2)
|
||||
for i, obj in pairs(objs) do
|
||||
if obj:is_player() then
|
||||
local n = minetest.get_node(pos)
|
||||
if n and n.name then
|
||||
if minetest.registered_nodes[n.name].crack and minetest.registered_nodes[n.name].crack < 2 then
|
||||
minetest.set_node(pos, {name="spawners:trap_2"})
|
||||
nodeupdate(pos)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
||||
minetest.register_node("spawners:trap", {
|
||||
description = "Cracked sandstone brick",
|
||||
tiles = {"default_sandstone_brick.png^pyramids_crack.png"},
|
||||
is_ground_content = true,
|
||||
groups = {crumbly=2,cracky=3},
|
||||
sounds = default.node_sound_stone_defaults(),
|
||||
on_construct = function(pos)
|
||||
minetest.get_node_timer(pos):start(0.1)
|
||||
end,
|
||||
crack = 1,
|
||||
on_timer = trap_on_timer,
|
||||
drop = "",
|
||||
})
|
||||
|
||||
minetest.register_node("spawners:trap_2", {
|
||||
description = "trapstone",
|
||||
tiles = {"default_sandstone_brick.png^pyramids_crack.png^[transformR90"},
|
||||
is_ground_content = true,
|
||||
groups = {crumbly=2,cracky=3,falling_node=1,not_in_creative_inventory=1},
|
||||
sounds = default.node_sound_stone_defaults(),
|
||||
drop = "",
|
||||
})
|
78
spawners_env/pyramids_room.lua
Normal file
@ -0,0 +1,78 @@
|
||||
local room = {"a","a","a","a","a","a","a","a","a",
|
||||
"a","c","a","c","a","c","a","c","a",
|
||||
"a","s","a","s","a","s","a","s","a",
|
||||
"a","a","a","a","a","a","a","a","a",
|
||||
"a","a","a","a","a","a","a","a","a",
|
||||
"a","a","a","a","a","a","a","a","a",
|
||||
"a","s","a","s","a","s","a","s","a",
|
||||
"a","c","a","c","a","c","a","c","a",
|
||||
"a","a","a","a","a","a","a","a","a"}
|
||||
|
||||
local trap = {"b","b","b","b","b","b","b","b","b",
|
||||
"l","b","l","b","l","b","l","b","b",
|
||||
"l","b","l","b","l","b","l","b","b",
|
||||
"l","b","l","l","l","b","l","l","b",
|
||||
"l","l","b","l","b","l","l","b","b",
|
||||
"l","b","l","l","l","l","l","l","b",
|
||||
"l","b","l","b","l","b","l","b","b",
|
||||
"l","b","l","b","l","b","l","b","b",
|
||||
"b","b","b","b","b","b","b","b","b"}
|
||||
|
||||
local code = {}
|
||||
code["s"] = "sandstone"
|
||||
code["eye"] = "deco_stone1"
|
||||
code["men"] = "deco_stone2"
|
||||
code["sun"] = "deco_stone3"
|
||||
code["c"] = "chest"
|
||||
code["b"] = "sandstonebrick"
|
||||
code["a"] = "air"
|
||||
code["l"] = "lava_source"
|
||||
code["t"] = "trap"
|
||||
|
||||
local function replace(str,iy)
|
||||
local out = "default:"
|
||||
if iy < 4 and str == "c" then str = "a" end
|
||||
if iy == 0 and str == "s" then out = "spawners:" str = "sun" end
|
||||
if iy == 3 and str == "s" then out = "spawners:" str = "men" end
|
||||
if str == "a" then out = "" end
|
||||
return out..code[str]
|
||||
end
|
||||
|
||||
local function replace2(str,iy)
|
||||
local out = "default:"
|
||||
if iy == 0 and str == "l" then out = "spawners:" str = "t"
|
||||
elseif iy < 3 and str == "l" then str = "a" end
|
||||
|
||||
if str == "a" then out = "" end
|
||||
return out..code[str]
|
||||
end
|
||||
|
||||
function pyramids.make_room(pos)
|
||||
local loch = {x=pos.x+7,y=pos.y+5, z=pos.z+7}
|
||||
for iy=0,4,1 do
|
||||
for ix=0,8,1 do
|
||||
for iz=0,8,1 do
|
||||
local n_str = room[tonumber(ix*9+iz+1)]
|
||||
local p2 = 0
|
||||
if n_str == "c" then
|
||||
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
|
||||
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
|
||||
|
||||
function pyramids.make_traps(pos)
|
||||
local loch = {x=pos.x+7,y=pos.y, z=pos.z+7}
|
||||
for iy=0,4,1 do
|
||||
for ix=0,8,1 do
|
||||
for iz=0,8,1 do
|
||||
local n_str = trap[tonumber(ix*9+iz+1)]
|
||||
local p2 = 0
|
||||
minetest.set_node({x=loch.x+ix,y=loch.y-iy,z=loch.z+iz}, {name=replace2(n_str,iy), param2=p2})
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
40
spawners_env/spawners_gen.lua
Normal file
@ -0,0 +1,40 @@
|
||||
-- Place spawners in dungeons
|
||||
local function place_spawner(param)
|
||||
local tab = param[1]
|
||||
local gen_obj = param[2]
|
||||
|
||||
local pos = tab[math.random(1, (#tab or 3))]
|
||||
pos.y = pos.y - 1
|
||||
|
||||
local n = minetest.get_node_or_nil(pos)
|
||||
|
||||
if n and n.name ~= "air" then
|
||||
pos.y = pos.y + 1
|
||||
|
||||
if gen_obj == "dungeon" then
|
||||
minetest.log("action", "[Mod][Spawners] dungeon spawner placed at: "..minetest.pos_to_string(pos))
|
||||
|
||||
minetest.set_node(pos, {name = "spawners:spawners_mummy_spawner_env"})
|
||||
else
|
||||
minetest.log("action", "[Mod][Spawners] temple spawner placed at: "..minetest.pos_to_string(pos))
|
||||
|
||||
minetest.set_node(pos, {name = "spawners:mobs_spider_spawner_env"})
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
minetest.set_gen_notify("dungeon")
|
||||
minetest.set_gen_notify("temple")
|
||||
|
||||
minetest.register_on_generated(function(minp, maxp, blockseed)
|
||||
local ntf = minetest.get_mapgen_object("gennotify")
|
||||
|
||||
if ntf and ntf.dungeon then
|
||||
minetest.after(3, place_spawner, {table.copy(ntf.dungeon), "dungeon"})
|
||||
end
|
||||
|
||||
if ntf and ntf.temple then
|
||||
minetest.after(3, place_spawner, {table.copy(ntf.temple), "temple"})
|
||||
end
|
||||
end)
|
185
spawners_mobs/api.lua
Normal file
@ -0,0 +1,185 @@
|
||||
-- main tables
|
||||
spawners = {}
|
||||
spawners.mob_tables = {}
|
||||
|
||||
-- check if mods exists and build tables
|
||||
for k, mob_mod in ipairs(ENABLED_MODS) do
|
||||
local modpath = minetest.get_modpath(mob_mod)
|
||||
-- list of mobs and their info
|
||||
if (modpath) then
|
||||
for j, mob in ipairs(MOBS_PROPS[mob_mod]) do
|
||||
local mob_egg = nil
|
||||
|
||||
-- disabled extra check for mobs redo due to incompatibility with Lua 5.1, this method is available from Lua 5.2
|
||||
-- if mob_mod == "mobs" and not (mobs.mod == "redo") then goto continue end
|
||||
|
||||
table.insert(spawners.mob_tables, {name=mob.name, mod_prefix=mob_mod, egg_name_custom=mob.egg_name_custom, dummy_size=mob.dummy_size, dummy_offset=mob.dummy_offset, dummy_mesh=mob.dummy_mesh, dummy_texture=mob.dummy_texture, night_only=mob.night_only, sound_custom=mob.sound_custom})
|
||||
|
||||
-- use custom egg or create a default egg
|
||||
if mob.egg_name_custom ~= "" then
|
||||
mob_egg = mob.egg_name_custom
|
||||
else
|
||||
mob_egg = mob_mod..":"..mob.name
|
||||
end
|
||||
|
||||
-- recipes
|
||||
minetest.register_craft({
|
||||
output = "spawners_mobs:"..mob_mod.."_"..mob.name.."_spawner",
|
||||
recipe = {
|
||||
{"default:diamondblock", "fire:flint_and_steel", "default:diamondblock"},
|
||||
{"xpanes:bar_flat", mob_egg, "xpanes:bar_flat"},
|
||||
{"default:diamondblock", "xpanes:bar_flat", "default:diamondblock"},
|
||||
}
|
||||
})
|
||||
|
||||
-- ::continue::
|
||||
end
|
||||
else
|
||||
-- print something ?
|
||||
end
|
||||
end
|
||||
|
||||
-- start spawning mobs
|
||||
function spawners.start_spawning(pos, how_many, mob_name, mod_prefix, sound_custom)
|
||||
if not (pos or how_many or mob_name) then return end
|
||||
|
||||
local sound_name
|
||||
-- remove 'spawners_mobs:' from the string
|
||||
local mob_name = string.sub(mob_name,15)
|
||||
|
||||
-- use custom sounds
|
||||
if sound_custom ~= "" then
|
||||
sound_name = sound_custom
|
||||
else
|
||||
sound_name = mod_prefix.."_"..mob_name
|
||||
end
|
||||
|
||||
-- use random colours for sheeps
|
||||
if mob_name == "sheep_white" then
|
||||
local mob_name1 = ""
|
||||
local sheep_colours = {"black", "blue", "brown", "cyan", "dark_green", "dark_grey", "green", "grey", "magenta", "orange", "pink", "red", "violet", "white", "yellow"}
|
||||
local random_colour = math.random(1, #sheep_colours)
|
||||
mob_name1 = string.split(mob_name, "_")
|
||||
mob_name1 = mob_name1[1]
|
||||
mob_name = mob_name1.."_"..sheep_colours[random_colour]
|
||||
end
|
||||
|
||||
for i=1,how_many do
|
||||
pos.y = pos.y+1
|
||||
local obj = minetest.add_entity(pos, mod_prefix..":"..mob_name)
|
||||
|
||||
if obj then
|
||||
if sound_name then
|
||||
minetest.sound_play(sound_name, {
|
||||
pos = pos,
|
||||
max_hear_distance = 32,
|
||||
gain = 5,
|
||||
})
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function spawners.check_around_radius(pos)
|
||||
local player_near = false
|
||||
local radius = 21
|
||||
|
||||
for _,obj in ipairs(minetest.get_objects_inside_radius(pos, radius)) do
|
||||
if obj:is_player() then
|
||||
player_near = true
|
||||
end
|
||||
end
|
||||
|
||||
return player_near
|
||||
end
|
||||
|
||||
function spawners.check_node_status(pos, mob, night_only)
|
||||
local player_near = spawners.check_around_radius(pos)
|
||||
|
||||
if player_near then
|
||||
local random_pos = false
|
||||
local min_node_light = 10
|
||||
local tod = minetest.get_timeofday() * 24000
|
||||
local node_light = minetest.get_node_light(pos)
|
||||
|
||||
if not node_light then
|
||||
return false
|
||||
end
|
||||
|
||||
local spawn_positions = {}
|
||||
local right = minetest.get_node({x=pos.x+1, y=pos.y, z=pos.z})
|
||||
local front = minetest.get_node({x=pos.x, y=pos.y, z=pos.z+1})
|
||||
local left = minetest.get_node({x=pos.x-1, y=pos.y, z=pos.z})
|
||||
local back = minetest.get_node({x=pos.x, y=pos.y, z=pos.z-1})
|
||||
local top = minetest.get_node({x=pos.x, y=pos.y+1, z=pos.z})
|
||||
local bottom = minetest.get_node({x=pos.x, y=pos.y-1, z=pos.z})
|
||||
|
||||
-- make sure that at least one side of the spawner is open
|
||||
if right.name == "air" then
|
||||
table.insert(spawn_positions, {x=pos.x+1.5, y=pos.y, z=pos.z})
|
||||
end
|
||||
if front.name == "air" then
|
||||
table.insert(spawn_positions, {x=pos.x, y=pos.y, z=pos.z+1.5})
|
||||
end
|
||||
if left.name == "air" then
|
||||
table.insert(spawn_positions, {x=pos.x-1.5, y=pos.y, z=pos.z})
|
||||
end
|
||||
if back.name == "air" then
|
||||
table.insert(spawn_positions, {x=pos.x, y=pos.y, z=pos.z-1.5})
|
||||
end
|
||||
if top.name == "air" then
|
||||
table.insert(spawn_positions, {x=pos.x, y=pos.y+1.5, z=pos.z})
|
||||
end
|
||||
if bottom.name == "air" then
|
||||
table.insert(spawn_positions, {x=pos.x, y=pos.y-1.5, z=pos.z})
|
||||
end
|
||||
|
||||
if #spawn_positions < 1 then
|
||||
-- spawner is cloed from all sides
|
||||
return false
|
||||
else
|
||||
-- pick random from the open sides
|
||||
local pick_random
|
||||
|
||||
if #spawn_positions == 1 then
|
||||
pick_random = #spawn_positions
|
||||
else
|
||||
pick_random = math.random(1,#spawn_positions)
|
||||
end
|
||||
|
||||
for k, v in pairs (spawn_positions) do
|
||||
if k == pick_random then
|
||||
random_pos = v
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- check the node above and below the found air node
|
||||
local node_above = minetest.get_node({x=random_pos.x, y=random_pos.y+1, z=random_pos.z}).name
|
||||
local node_below = minetest.get_node({x=random_pos.x, y=random_pos.y-1, z=random_pos.z}).name
|
||||
|
||||
if not (node_above == "air" or node_below == "air") then
|
||||
return false
|
||||
end
|
||||
|
||||
if night_only ~= "disable" then
|
||||
-- spawn only at day
|
||||
if not night_only and node_light < min_node_light then
|
||||
return false, true
|
||||
end
|
||||
|
||||
-- spawn only at night
|
||||
if night_only then
|
||||
if not (19359 > tod and tod > 5200) or node_light < min_node_light then
|
||||
return random_pos
|
||||
else
|
||||
return false, true
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return random_pos, false
|
||||
else
|
||||
return false, true
|
||||
end
|
||||
end
|
204
spawners_mobs/config.example.lua
Normal file
@ -0,0 +1,204 @@
|
||||
-- * [name : string] - Name of the mob used in the mod.
|
||||
|
||||
-- [egg_name_custom : string] - Custom name for the egg item. If empty default name will be used i.e. 'mobs:chicken'.
|
||||
|
||||
-- * [dummy_size : table] - Size of the rotating dummy inside the node.
|
||||
|
||||
-- * [dummy_offset : integer] - Offset on Y axis of the dummy inside the node.
|
||||
|
||||
-- * [dummy_mesh : string] - Filename of the model used fot he mob.
|
||||
|
||||
-- * [dummy_texture : table] - Textures used for the mob.
|
||||
|
||||
-- * [night_only : boolean : string] - If true mobs will spawn only during the night or in dark areas, default:true. Writing "disable" will disable light check and it will spawn in both states (night and day)
|
||||
|
||||
-- [sound_custom : string] - Custom name for the sound file name if differ from default: i.e 'mobs_cow'.
|
||||
|
||||
-- [*] -> MANDATORY - has to be filled in!
|
||||
|
||||
-- mods what should be enabled and loded, remove/add the one you want to load
|
||||
ENABLED_MODS = {"mobs", "creatures"}
|
||||
|
||||
-- mobs properties - setup all you mobs here
|
||||
MOBS_PROPS = {
|
||||
|
||||
["mobs"] = { -- MOBS REDO CONFIG
|
||||
{
|
||||
name="sheep_white",
|
||||
egg_name_custom="",
|
||||
dummy_size={x=0.52,y=0.52},
|
||||
dummy_offset=0.2,
|
||||
dummy_mesh="mobs_sheep.b3d",
|
||||
dummy_texture={"mobs_sheep_wool.png^mobs_sheep_base.png"},
|
||||
night_only=false,
|
||||
sound_custom="mobs_sheep"
|
||||
},
|
||||
{
|
||||
name="cow",
|
||||
egg_name_custom="",
|
||||
dummy_size={x=0.3,y=0.3},
|
||||
dummy_offset=-0.3,
|
||||
dummy_mesh="mobs_cow.x",
|
||||
dummy_texture={"mobs_cow.png"},
|
||||
night_only=false,
|
||||
sound_custom=""
|
||||
},
|
||||
{
|
||||
name="chicken",
|
||||
egg_name_custom="",
|
||||
dummy_size={x=0.9,y=0.9},
|
||||
dummy_offset=0.2,
|
||||
dummy_mesh="mobs_chicken.x",
|
||||
dummy_texture={"mobs_chicken.png", "mobs_chicken.png", "mobs_chicken.png", "mobs_chicken.png", "mobs_chicken.png", "mobs_chicken.png", "mobs_chicken.png", "mobs_chicken.png", "mobs_chicken.png"},
|
||||
night_only=false,
|
||||
sound_custom=""
|
||||
},
|
||||
{
|
||||
name="pumba",
|
||||
egg_name_custom="",
|
||||
dummy_size={x=0.62,y=0.62},
|
||||
dummy_offset=-0.3,
|
||||
dummy_mesh="mobs_pumba.x",
|
||||
dummy_texture={"mobs_pumba.png"},
|
||||
night_only=false,
|
||||
sound_custom="mobs_pig"
|
||||
},
|
||||
{
|
||||
name="bunny",
|
||||
egg_name_custom="",
|
||||
dummy_size={x=1,y=1},
|
||||
dummy_offset=0.2,
|
||||
dummy_mesh="mobs_bunny.b3d",
|
||||
dummy_texture={"mobs_bunny_brown.png"},
|
||||
night_only=false,
|
||||
sound_custom="spawners_mobs_bunny"
|
||||
},
|
||||
{
|
||||
name="kitten",
|
||||
egg_name_custom="",
|
||||
dummy_size={x=0.32,y=0.32},
|
||||
dummy_offset=0,
|
||||
dummy_mesh="mobs_kitten.b3d",
|
||||
dummy_texture={"mobs_kitten_ginger.png"},
|
||||
night_only=false,
|
||||
sound_custom=""
|
||||
},
|
||||
{
|
||||
name="spider",
|
||||
egg_name_custom="",
|
||||
dummy_size={x=2,y=2},
|
||||
dummy_offset=-0.2,
|
||||
dummy_mesh="mobs_spider.x",
|
||||
dummy_texture={"mobs_spider.png"},
|
||||
night_only=false,
|
||||
sound_custom=""
|
||||
},
|
||||
{
|
||||
name="stone_monster",
|
||||
egg_name_custom="",
|
||||
dummy_size={x=0.5,y=0.5},
|
||||
dummy_offset=0.05,
|
||||
dummy_mesh="mobs_stone_monster.b3d",
|
||||
dummy_texture={"mobs_stone_monster.png"},
|
||||
night_only=false,
|
||||
sound_custom="mobs_stonemonster"
|
||||
},
|
||||
{
|
||||
name="oerkki",
|
||||
egg_name_custom="",
|
||||
dummy_size={x=0.5,y=0.5},
|
||||
dummy_offset=0.05,
|
||||
dummy_mesh="mobs_oerkki.b3d",
|
||||
dummy_texture={"mobs_oerkki.png"},
|
||||
night_only=true,
|
||||
sound_custom=""
|
||||
},
|
||||
{
|
||||
name="tree_monster",
|
||||
egg_name_custom="",
|
||||
dummy_size={x=0.4,y=0.4},
|
||||
dummy_offset=0.05,
|
||||
dummy_mesh="mobs_tree_monster.b3d",
|
||||
dummy_texture={"mobs_tree_monster.png"},
|
||||
night_only=true,
|
||||
sound_custom="mobs_treemonster"
|
||||
}
|
||||
},
|
||||
|
||||
["creatures"] = { -- CREATURES MOD CONFIG
|
||||
{
|
||||
name="chicken",
|
||||
egg_name_custom="creatures:chicken_spawn_egg",
|
||||
dummy_size={x=0.9,y=0.9},
|
||||
dummy_offset=-0.3,
|
||||
dummy_mesh="creatures_chicken.b3d",
|
||||
dummy_texture={"creatures_chicken.png"},
|
||||
night_only=false,
|
||||
sound_custom=""
|
||||
},
|
||||
{
|
||||
name="ghost",
|
||||
egg_name_custom="creatures:ghost_spawn_egg",
|
||||
dummy_size={x=0.7,y=0.7},
|
||||
dummy_offset=-0.5,
|
||||
dummy_mesh="creatures_ghost.b3d",
|
||||
dummy_texture={"creatures_ghost.png"},
|
||||
night_only=true,
|
||||
sound_custom=""
|
||||
},
|
||||
{
|
||||
name="sheep",
|
||||
egg_name_custom="creatures:sheep_spawn_egg",
|
||||
dummy_size={x=0.6,y=0.6},
|
||||
dummy_offset=-0.3,
|
||||
dummy_mesh="creatures_sheep.b3d",
|
||||
dummy_texture={"creatures_sheep.png^creatures_sheep_white.png"},
|
||||
night_only=false,
|
||||
sound_custom=""
|
||||
},
|
||||
{
|
||||
name="zombie",
|
||||
egg_name_custom="creatures:zombie_spawn_egg",
|
||||
dummy_size={x=0.5,y=0.5},
|
||||
dummy_offset=-0.5,
|
||||
dummy_mesh="creatures_zombie.b3d",
|
||||
dummy_texture={"creatures_zombie.png"},
|
||||
night_only=false,
|
||||
sound_custom=""
|
||||
},
|
||||
{
|
||||
name="oerrki",
|
||||
egg_name_custom="creatures:oerrki_spawn_egg",
|
||||
dummy_size={x=0.4,y=0.4},
|
||||
dummy_offset=-0.5,
|
||||
dummy_mesh="creatures_oerrki.b3d",
|
||||
dummy_texture={"creatures_oerrki.png"},
|
||||
night_only=false,
|
||||
sound_custom="creatures_oerrki_idle"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
--
|
||||
-- check for 3rd party dependencies
|
||||
--
|
||||
|
||||
-- include mummy mobs redo addon (spawner)
|
||||
if minetest.get_modpath("mobs") ~= nil then
|
||||
-- enable spawner
|
||||
table.insert(ENABLED_MODS, "spawners")
|
||||
|
||||
-- configure spawner
|
||||
MOBS_PROPS["spawners"] = {
|
||||
{
|
||||
name="mummy",
|
||||
egg_name_custom="",
|
||||
dummy_size={x=0.4,y=0.4},
|
||||
dummy_offset=0,
|
||||
dummy_mesh="spawners_mobs_mummy.b3d",
|
||||
dummy_texture={"spawners_mobs_mummy.png"},
|
||||
night_only="disable",
|
||||
sound_custom="spawners_mobs_mummy"
|
||||
}
|
||||
}
|
||||
end
|
5
spawners_mobs/depends.txt
Normal file
@ -0,0 +1,5 @@
|
||||
default
|
||||
xpanes?
|
||||
fire?
|
||||
mobs?
|
||||
creatures?
|
18
spawners_mobs/init.lua
Normal file
@ -0,0 +1,18 @@
|
||||
MOD_NAME = minetest.get_current_modname()
|
||||
|
||||
-- Spawners configurations
|
||||
dofile(minetest.get_modpath(MOD_NAME).."/config.lua")
|
||||
|
||||
-- API
|
||||
dofile(minetest.get_modpath(MOD_NAME).."/api.lua")
|
||||
|
||||
-- Spawners for mobs
|
||||
dofile(minetest.get_modpath(MOD_NAME).."/spawners_mobs.lua")
|
||||
|
||||
-- include mummy mobs redo addon (mob)
|
||||
if minetest.get_modpath("mobs") then
|
||||
dofile(minetest.get_modpath(MOD_NAME).."/mob_mummy.lua")
|
||||
dofile(minetest.get_modpath(MOD_NAME).."/nodes_additional.lua")
|
||||
end
|
||||
|
||||
print ("[Mod] Spawners Mobs 0.6 Loaded.")
|
65
spawners_mobs/mob_mummy.lua
Normal file
@ -0,0 +1,65 @@
|
||||
-- modified Sand Monster by PilzAdam with Mummy by BlockMen
|
||||
|
||||
local mummy_def = {
|
||||
type = "monster",
|
||||
passive = false,
|
||||
attack_type = "dogfight",
|
||||
pathfinding = true,
|
||||
reach = 2,
|
||||
damage = 4,
|
||||
hp_min = 25,
|
||||
hp_max = 35,
|
||||
armor = 100,
|
||||
collisionbox = {-0.4, -1, -0.4, 0.4, 0.8, 0.4},
|
||||
visual = "mesh",
|
||||
mesh = "spawners_mobs_mummy.b3d",
|
||||
textures = {
|
||||
{"spawners_mobs_mummy.png"},
|
||||
},
|
||||
makes_footstep_sound = true,
|
||||
sounds = {
|
||||
random = "spawners_mobs_mummy",
|
||||
damage = "spawners_mobs_mummy_hit",
|
||||
},
|
||||
walk_velocity = .75,
|
||||
run_velocity = 1.5,
|
||||
view_range = 8,
|
||||
jump = true,
|
||||
floats = 0,
|
||||
drops = {
|
||||
{name = "default:sandstone", chance = 1, min = 1, max = 3},
|
||||
{name = "default:sandstonebrick", chance = 2, min = 1, max = 2},
|
||||
{name = "spawners_mobs:deco_stone_eye", chance = 15, min = 1, max = 1},
|
||||
{name = "spawners_mobs:deco_stone_men", chance = 15, min = 1, max = 1},
|
||||
{name = "spawners_mobs:deco_stone_sun", chance = 15, min = 1, max = 1},
|
||||
},
|
||||
water_damage = 4,
|
||||
lava_damage = 8,
|
||||
light_damage = 0,
|
||||
fear_height = 4,
|
||||
animation = {
|
||||
speed_normal = 15,
|
||||
speed_run = 15,
|
||||
stand_start = 0,
|
||||
stand_end = 39,
|
||||
walk_start = 41,
|
||||
walk_end = 72,
|
||||
run_start = 74,
|
||||
run_end = 105,
|
||||
punch_start = 74,
|
||||
punch_end = 105,
|
||||
},
|
||||
on_die = function(self, pos)
|
||||
minetest.sound_play("spawners_mobs_mummy_death", {
|
||||
object = self.object,
|
||||
pos = pos,
|
||||
max_hear_distance = 10
|
||||
})
|
||||
end,
|
||||
}
|
||||
|
||||
mobs:register_mob("spawners_mobs:mummy", mummy_def)
|
||||
|
||||
mobs:register_spawn("spawners_mobs:mummy", {"default:desert_sand", "default:desert_stone"}, 20, 0, 14000, 2, 31000)
|
||||
|
||||
mobs:register_egg("spawners_mobs:mummy", "Mummy Monster", "default_sandstone_brick.png", 1)
|
11
spawners_mobs/nodes_additional.lua
Normal file
@ -0,0 +1,11 @@
|
||||
local img = {"eye", "men", "sun"}
|
||||
|
||||
for i=1,3 do
|
||||
minetest.register_node("spawners_mobs:deco_stone_"..img[i], {
|
||||
description = "Sandstone with "..img[i],
|
||||
tiles = {"default_sandstone.png^spawners_mobs_"..img[i]..".png"},
|
||||
is_ground_content = true,
|
||||
groups = {crumbly=2,cracky=3},
|
||||
sounds = default.node_sound_stone_defaults(),
|
||||
})
|
||||
end
|
243
spawners_mobs/spawners_mobs.lua
Normal file
@ -0,0 +1,243 @@
|
||||
local max_obj_per_mapblock = tonumber(minetest.setting_get("max_objects_per_block"))
|
||||
|
||||
--
|
||||
-- * CREATE ALL SPAWNERS NODES *
|
||||
--
|
||||
|
||||
function spawners.create(mob_name, mod_prefix, size, offset, mesh, texture, night_only, sound_custom)
|
||||
|
||||
--
|
||||
-- DUMMY INSIDE THE SPAWNER
|
||||
--
|
||||
|
||||
local dummy_definition = {
|
||||
hp_max = 1,
|
||||
physical = true,
|
||||
collisionbox = {0,0,0,0,0,0},
|
||||
visual = "mesh",
|
||||
visual_size = size,
|
||||
mesh = mesh,
|
||||
textures = texture,
|
||||
makes_footstep_sound = false,
|
||||
timer = 0,
|
||||
automatic_rotate = math.pi * -3,
|
||||
m_name = "dummy"
|
||||
}
|
||||
|
||||
dummy_definition.on_activate = function(self)
|
||||
self.object:setvelocity({x=0, y=0, z=0})
|
||||
self.object:setacceleration({x=0, y=0, z=0})
|
||||
self.object:set_armor_groups({immortal=1})
|
||||
end
|
||||
|
||||
-- remove dummy after dug up the spawner
|
||||
dummy_definition.on_step = function(self, dtime)
|
||||
self.timer = self.timer + dtime
|
||||
local n = minetest.get_node_or_nil(self.object:getpos())
|
||||
if self.timer > 2 then
|
||||
if n and n.name and n.name ~= "spawners_mobs:"..mod_prefix.."_"..mob_name.."_spawner_active" then
|
||||
self.object:remove()
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
minetest.register_entity("spawners_mobs:dummy_"..mod_prefix.."_"..mob_name, dummy_definition)
|
||||
|
||||
--
|
||||
-- * CRAFTING SPAWNERS *
|
||||
--
|
||||
|
||||
-- print("[Mod][Spawners] Registering Crafting Spawner.")
|
||||
|
||||
--
|
||||
-- ACTIVE SPAWNER
|
||||
--
|
||||
|
||||
minetest.register_node("spawners_mobs:"..mod_prefix.."_"..mob_name.."_spawner_active", {
|
||||
description = mod_prefix.."_"..mob_name.." spawner active",
|
||||
paramtype = "light",
|
||||
light_source = 4,
|
||||
drawtype = "allfaces",
|
||||
walkable = true,
|
||||
sounds = default.node_sound_stone_defaults(),
|
||||
damage_per_second = 4,
|
||||
sunlight_propagates = true,
|
||||
tiles = {
|
||||
{
|
||||
name = "spawners_mobs_spawner_animated.png",
|
||||
animation = {
|
||||
type = "vertical_frames",
|
||||
aspect_w = 32,
|
||||
aspect_h = 32,
|
||||
length = 2.0
|
||||
},
|
||||
}
|
||||
},
|
||||
is_ground_content = true,
|
||||
groups = {cracky=1,level=2,igniter=1,not_in_creative_inventory=1},
|
||||
drop = "spawners_mobs:"..mod_prefix.."_"..mob_name.."_spawner",
|
||||
on_construct = function(pos)
|
||||
pos.y = pos.y + offset
|
||||
minetest.add_entity(pos,"spawners_mobs:dummy_"..mod_prefix.."_"..mob_name)
|
||||
end,
|
||||
})
|
||||
|
||||
--
|
||||
-- WAITING SPAWNER
|
||||
--
|
||||
|
||||
-- waiting for light - everything is ok but too much light or not enough light
|
||||
minetest.register_node("spawners_mobs:"..mod_prefix.."_"..mob_name.."_spawner_waiting", {
|
||||
description = mod_prefix.."_"..mob_name.." spawner waiting",
|
||||
paramtype = "light",
|
||||
light_source = 2,
|
||||
drawtype = "allfaces",
|
||||
walkable = true,
|
||||
sounds = default.node_sound_stone_defaults(),
|
||||
sunlight_propagates = true,
|
||||
tiles = {
|
||||
{
|
||||
name = "spawners_mobs_spawner_waiting_animated.png",
|
||||
animation = {
|
||||
type = "vertical_frames",
|
||||
aspect_w = 32,
|
||||
aspect_h = 32,
|
||||
length = 2.0
|
||||
},
|
||||
}
|
||||
},
|
||||
is_ground_content = true,
|
||||
groups = {cracky=1,level=2,not_in_creative_inventory=1},
|
||||
drop = "spawners_mobs:"..mod_prefix.."_"..mob_name.."_spawner",
|
||||
})
|
||||
|
||||
--
|
||||
-- INACTIVE SPAWNER (DEFAULT)
|
||||
--
|
||||
|
||||
minetest.register_node("spawners_mobs:"..mod_prefix.."_"..mob_name.."_spawner", {
|
||||
description = mod_prefix.."_"..mob_name.." spawner",
|
||||
paramtype = "light",
|
||||
drawtype = "allfaces",
|
||||
walkable = true,
|
||||
sounds = default.node_sound_stone_defaults(),
|
||||
sunlight_propagates = true,
|
||||
tiles = {"spawners_mobs_spawner.png"},
|
||||
is_ground_content = true,
|
||||
groups = {cracky=1,level=2},
|
||||
stack_max = 1,
|
||||
on_construct = function(pos)
|
||||
local random_pos, waiting = spawners.check_node_status(pos, mob_name, night_only)
|
||||
|
||||
if random_pos then
|
||||
minetest.set_node(pos, {name="spawners_mobs:"..mod_prefix.."_"..mob_name.."_spawner_active"})
|
||||
elseif waiting then
|
||||
minetest.set_node(pos, {name="spawners_mobs:"..mod_prefix.."_"..mob_name.."_spawner_waiting"})
|
||||
else
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
||||
--
|
||||
-- OVERHEATED SPAWNER
|
||||
--
|
||||
|
||||
minetest.register_node("spawners_mobs:"..mod_prefix.."_"..mob_name.."_spawner_overheat", {
|
||||
description = mod_prefix.."_"..mob_name.." spawner overheated",
|
||||
paramtype = "light",
|
||||
light_source = 2,
|
||||
drawtype = "allfaces",
|
||||
walkable = true,
|
||||
sounds = default.node_sound_stone_defaults(),
|
||||
damage_per_second = 4,
|
||||
sunlight_propagates = true,
|
||||
tiles = {"spawners_mobs_spawner.png^[colorize:#FF000030"},
|
||||
is_ground_content = true,
|
||||
groups = {cracky=1,level=2,igniter=1,not_in_creative_inventory=1},
|
||||
drop = "spawners_mobs:"..mod_prefix.."_"..mob_name.."_spawner",
|
||||
on_construct = function(pos)
|
||||
minetest.get_node_timer(pos):start(60)
|
||||
end,
|
||||
on_timer = function(pos, elapsed)
|
||||
minetest.set_node(pos, {name="spawners_mobs:"..mod_prefix.."_"..mob_name.."_spawner"})
|
||||
end,
|
||||
})
|
||||
|
||||
--
|
||||
-- * ABM *
|
||||
--
|
||||
|
||||
minetest.register_abm({
|
||||
nodenames = {
|
||||
"spawners_mobs:"..mod_prefix.."_"..mob_name.."_spawner",
|
||||
"spawners_mobs:"..mod_prefix.."_"..mob_name.."_spawner_active",
|
||||
"spawners_mobs:"..mod_prefix.."_"..mob_name.."_spawner_overheat",
|
||||
"spawners_mobs:"..mod_prefix.."_"..mob_name.."_spawner_waiting"
|
||||
},
|
||||
neighbors = {"air"},
|
||||
interval = 10.0,
|
||||
chance = 6,
|
||||
catch_up = false,
|
||||
action = function(pos, node, active_object_count, active_object_count_wider)
|
||||
|
||||
local random_pos, waiting = spawners.check_node_status(pos, mob_name, night_only)
|
||||
|
||||
-- minetest.log("action", "[Mod][Spawners] checking for: "..mob_name.." at "..minetest.pos_to_string(pos))
|
||||
|
||||
if random_pos then
|
||||
|
||||
-- do not spawn if too many active entities in map block and call cooldown
|
||||
if active_object_count_wider > max_obj_per_mapblock then
|
||||
|
||||
-- make sure the right node status is shown
|
||||
if node.name ~= "spawners_mobs:"..mob_name.."_spawner_overheat" then
|
||||
minetest.set_node(pos, {name="spawners_mobs:"..mod_prefix.."_"..mob_name.."_spawner_overheat"})
|
||||
end
|
||||
|
||||
-- extend the timeout if still too many entities in map block
|
||||
if node.name == "spawners_mobs:"..mod_prefix.."_"..mob_name.."_spawner_overheat" then
|
||||
minetest.get_node_timer(pos):stop()
|
||||
minetest.get_node_timer(pos):start(60)
|
||||
end
|
||||
|
||||
return
|
||||
end
|
||||
-- make sure the right node status is shown
|
||||
if node.name ~= "spawners_mobs:"..mod_prefix.."_"..mob_name.."_spawner_active" then
|
||||
minetest.set_node(pos, {name="spawners_mobs:"..mod_prefix.."_"..mob_name.."_spawner_active"})
|
||||
end
|
||||
|
||||
-- enough place to spawn more mobs
|
||||
spawners.start_spawning(random_pos, 1, "spawners_mobs:"..mob_name, mod_prefix, sound_custom)
|
||||
|
||||
elseif waiting then
|
||||
-- waiting status
|
||||
if node.name ~= "spawners_mobs:"..mod_prefix.."_"..mob_name.."_spawner_waiting" then
|
||||
minetest.set_node(pos, {name="spawners_mobs:"..mod_prefix.."_"..mob_name.."_spawner_waiting"})
|
||||
end
|
||||
else
|
||||
-- no random_pos found
|
||||
if minetest.get_node_timer(pos):is_started() then
|
||||
minetest.get_node_timer(pos):stop()
|
||||
end
|
||||
|
||||
if node.name ~= "spawners_mobs:"..mod_prefix.."_"..mob_name.."_spawner" then
|
||||
minetest.set_node(pos, {name="spawners_mobs:"..mod_prefix.."_"..mob_name.."_spawner"})
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
})
|
||||
|
||||
end
|
||||
|
||||
--
|
||||
-- CALL 'CREATE' FOR ALL SPAWNERS
|
||||
--
|
||||
|
||||
for i, mob_table in ipairs(spawners.mob_tables) do
|
||||
if mob_table then
|
||||
|
||||
spawners.create(mob_table.name, mob_table.mod_prefix, mob_table.dummy_size, mob_table.dummy_offset, mob_table.dummy_mesh, mob_table.dummy_texture, mob_table.night_only, mob_table.sound_custom)
|
||||
end
|
||||
end
|
Before Width: | Height: | Size: 390 B After Width: | Height: | Size: 390 B |
Before Width: | Height: | Size: 248 B After Width: | Height: | Size: 248 B |
Before Width: | Height: | Size: 240 B After Width: | Height: | Size: 240 B |
Before Width: | Height: | Size: 1.9 KiB After Width: | Height: | Size: 1.9 KiB |
Before Width: | Height: | Size: 233 B After Width: | Height: | Size: 233 B |
Before Width: | Height: | Size: 535 B After Width: | Height: | Size: 535 B |
Before Width: | Height: | Size: 18 KiB After Width: | Height: | Size: 18 KiB |
Before Width: | Height: | Size: 7.8 KiB After Width: | Height: | Size: 7.8 KiB |
Before Width: | Height: | Size: 4.6 KiB After Width: | Height: | Size: 4.6 KiB |
Before Width: | Height: | Size: 231 B After Width: | Height: | Size: 231 B |
93
spawners_ores/api.lua
Normal file
@ -0,0 +1,93 @@
|
||||
-- main tables
|
||||
spawners = {}
|
||||
|
||||
function spawners.add_effects(pos, radius)
|
||||
minetest.add_particlespawner({
|
||||
amount = 32,
|
||||
time = 2,
|
||||
minpos = vector.subtract({x=pos.x, y=pos.y+1, z=pos.z}, radius / 2),
|
||||
maxpos = vector.add({x=pos.x, y=pos.y+1, z=pos.z}, radius / 2),
|
||||
minvel = {x=-0.5, y=3, z=-0.5},
|
||||
maxvel = {x=0.5, y=10, z=0.5},
|
||||
minacc = vector.new(),
|
||||
maxacc = vector.new(),
|
||||
minexptime = .5,
|
||||
maxexptime = 2,
|
||||
minsize = .5,
|
||||
maxsize = 8,
|
||||
texture = "spawners_smoke_particle.png",
|
||||
})
|
||||
end
|
||||
|
||||
-- start spawning ores
|
||||
function spawners.start_spawning_ores(pos, ore_name, sound_custom, spawners_pos)
|
||||
if not pos or not ore_name then return end
|
||||
local sound_name
|
||||
local player_near = false
|
||||
|
||||
-- use custom sounds
|
||||
if sound_custom ~= "" then
|
||||
sound_name = sound_custom
|
||||
else
|
||||
sound_name = false
|
||||
end
|
||||
|
||||
local how_many = math.random(1,2)
|
||||
-- how_many = how_many+1
|
||||
|
||||
for i=1, how_many do
|
||||
|
||||
if i > 1 then
|
||||
player_near, pos = spawners.check_around_radius_ores(pos, "default:stone")
|
||||
|
||||
if not pos then return end
|
||||
|
||||
minetest.sound_play(sound_name, {
|
||||
pos = pos,
|
||||
max_hear_distance = 32,
|
||||
gain = 20,
|
||||
})
|
||||
|
||||
minetest.set_node(pos, {name=ore_name})
|
||||
spawners.add_effects(pos, 1)
|
||||
else
|
||||
minetest.sound_play(sound_name, {
|
||||
pos = pos,
|
||||
max_hear_distance = 32,
|
||||
gain = 20,
|
||||
})
|
||||
|
||||
minetest.set_node(pos, {name=ore_name})
|
||||
spawners.add_effects(pos, 1)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
function spawners.check_around_radius_ores(pos, check_node)
|
||||
local player_near = spawners.check_around_radius(pos);
|
||||
local found_node = false
|
||||
local node_ore_pos = nil
|
||||
if check_node then
|
||||
|
||||
node_ore_pos = minetest.find_node_near(pos, 2, {check_node})
|
||||
|
||||
if node_ore_pos then
|
||||
found_node = node_ore_pos
|
||||
end
|
||||
end
|
||||
|
||||
return player_near, found_node
|
||||
end
|
||||
|
||||
function spawners.check_node_status_ores(pos, ore_name, check_node)
|
||||
if not check_node then return end
|
||||
|
||||
local player_near, found_node = spawners.check_around_radius_ores(pos, check_node)
|
||||
|
||||
if player_near and found_node then
|
||||
return true, found_node
|
||||
else
|
||||
return true, false
|
||||
end
|
||||
end
|
1
spawners_ores/depends.txt
Normal file
@ -0,0 +1 @@
|
||||
default
|
42
spawners_ores/init.lua
Normal file
@ -0,0 +1,42 @@
|
||||
-- Main settings
|
||||
dofile(minetest.get_modpath("spawners").."/settings.txt")
|
||||
|
||||
-- Spawners configurations
|
||||
dofile(minetest.get_modpath("spawners").."/config.lua")
|
||||
|
||||
-- API
|
||||
dofile(minetest.get_modpath("spawners").."/API.lua")
|
||||
|
||||
-- Spawners for mobs
|
||||
dofile(minetest.get_modpath("spawners").."/spawners_mobs.lua")
|
||||
|
||||
-- Spawners for ores
|
||||
dofile(minetest.get_modpath("spawners").."/spawners_ores.lua")
|
||||
|
||||
-- include mummy mobs redo addon (mob)
|
||||
if minetest.get_modpath("mobs") then
|
||||
dofile(minetest.get_modpath("spawners").."/mob_mummy.lua")
|
||||
end
|
||||
|
||||
-- Spawners Pyramids
|
||||
if SPAWN_PYRAMIDS then
|
||||
dofile(minetest.get_modpath("spawners").."/pyramids.lua")
|
||||
|
||||
print("[Mod][spawners] Pyramids enabled")
|
||||
end
|
||||
|
||||
-- Add Spawners to dungeons, temples..
|
||||
if SPAWNERS_GENERATE then
|
||||
dofile(minetest.get_modpath("spawners").."/spawners_gen.lua")
|
||||
|
||||
print("[Mod][spawners] Spawners generate enabled")
|
||||
end
|
||||
|
||||
-- Add Chests to dungeons, temples..
|
||||
if CHESTS_GENERATE then
|
||||
dofile(minetest.get_modpath("spawners").."/chests_gen.lua")
|
||||
|
||||
print("[Mod][spawners] Chests generate enabled")
|
||||
end
|
||||
|
||||
print ("[Mod] Spawners 0.6 Loaded.")
|
335
spawners_ores/spawners_ores.lua
Normal file
@ -0,0 +1,335 @@
|
||||
-- Formspecs
|
||||
local ore_formspec =
|
||||
"size[8,8.5]"..
|
||||
default.gui_bg..
|
||||
default.gui_bg_img..
|
||||
default.gui_slots..
|
||||
"label[2,1.7;Input Ingot]"..
|
||||
"list[current_name;fuel;3.5,1.5;1,1;]"..
|
||||
"list[current_player;main;0,4.25;8,1;]"..
|
||||
"list[current_player;main;0,5.5;8,3;8]"..
|
||||
"button_exit[5,1.5;2,1;exit;Save]"..
|
||||
"listring[current_name;fuel]"..
|
||||
"listring[current_player;main]"..
|
||||
default.get_hotbar_bg(0, 4.25)
|
||||
|
||||
function spawners.get_formspec(pos)
|
||||
|
||||
-- Inizialize metadata
|
||||
local meta = minetest.get_meta(pos)
|
||||
|
||||
-- Inizialize inventory
|
||||
local inv = meta:get_inventory()
|
||||
for listname, size in pairs({
|
||||
fuel = 1,
|
||||
}) do
|
||||
if inv:get_size(listname) ~= size then
|
||||
inv:set_size(listname, size)
|
||||
end
|
||||
end
|
||||
|
||||
-- Update formspec, infotext and node
|
||||
meta:set_string("formspec", ore_formspec)
|
||||
end
|
||||
|
||||
local function can_dig(pos, player)
|
||||
local meta = minetest.get_meta(pos);
|
||||
local inv = meta:get_inventory()
|
||||
return inv:is_empty("fuel")
|
||||
end
|
||||
|
||||
local function allow_metadata_inventory_put(pos, listname, index, stack, player)
|
||||
if minetest.is_protected(pos, player:get_player_name()) then
|
||||
minetest.record_protection_violation(pos, player:get_player_name())
|
||||
return
|
||||
end
|
||||
local meta = minetest.get_meta(pos)
|
||||
local inv = meta:get_inventory()
|
||||
local ingot = minetest.get_node_or_nil(pos).name
|
||||
|
||||
ingot = string.split(ingot, ":")
|
||||
ingot = string.split(ingot[2], "_")
|
||||
|
||||
if ingot[3] == "iron" then
|
||||
ingot[3] = "steel"
|
||||
end
|
||||
|
||||
if stack:get_name() == "default:"..ingot[3].."_ingot" then
|
||||
return stack:get_count()
|
||||
else
|
||||
return 0
|
||||
end
|
||||
end
|
||||
|
||||
local function allow_metadata_inventory_take(pos, listname, index, stack, player)
|
||||
if minetest.is_protected(pos, player:get_player_name()) then
|
||||
minetest.record_protection_violation(pos, player:get_player_name())
|
||||
return 0
|
||||
end
|
||||
return stack:get_count()
|
||||
end
|
||||
|
||||
local function on_receive_fields(pos, formname, fields, sender)
|
||||
local ore_node = minetest.get_node_or_nil(pos)
|
||||
|
||||
if minetest.is_protected(pos, sender:get_player_name()) then
|
||||
minetest.record_protection_violation(pos, sender:get_player_name())
|
||||
return
|
||||
end
|
||||
|
||||
-- get the ore name
|
||||
local ingot = ore_node.name
|
||||
ingot = string.split(ingot, ":")
|
||||
ingot = string.split(ingot[2], "_")
|
||||
|
||||
local meta = minetest.get_meta(pos)
|
||||
local inv = meta:get_inventory()
|
||||
local fuellist = inv:get_list("fuel")
|
||||
|
||||
if inv:is_empty("fuel") then
|
||||
if ore_node.name ~= "spawners:stone_with_"..ingot[3].."_spawner" then
|
||||
minetest.swap_node(pos, {name="spawners:stone_with_"..ingot[3].."_spawner"})
|
||||
end
|
||||
meta:set_string("infotext", ingot[3].." ore spawner is empty")
|
||||
else
|
||||
meta:set_string("infotext", ingot[3].." ore spawner fuel: "..inv:get_stack("fuel", 1):get_count())
|
||||
end
|
||||
|
||||
-- fix iron vs. steel issue
|
||||
if ingot[3] == "iron" then
|
||||
ingot[3] = "steel"
|
||||
end
|
||||
|
||||
if not fuellist[1]:is_empty() and inv:get_stack("fuel", 1):get_name() == "default:"..ingot[3].."_ingot" then
|
||||
|
||||
-- fix iron vs. steel issue
|
||||
if ingot[3] == "steel" then
|
||||
ingot[3] = "iron"
|
||||
end
|
||||
|
||||
local waiting, found_node = spawners.check_node_status_ores(pos, "stone_with_"..ingot[3], "default:stone")
|
||||
|
||||
if found_node then
|
||||
minetest.swap_node(pos, {name="spawners:stone_with_"..ingot[3].."_spawner_active"})
|
||||
elseif waiting then
|
||||
minetest.swap_node(pos, {name="spawners:stone_with_"..ingot[3].."_spawner_waiting"})
|
||||
|
||||
meta:set_string("infotext", "Waiting status - player was away or no stone around, "..ingot[3].." ore spawner fuel: "..inv:get_stack("fuel", 1):get_count())
|
||||
else
|
||||
return
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- Ores creation
|
||||
function spawners.create_ore(ore_name, mod_prefix, size, offset, texture, sound_custom)
|
||||
-- dummy inside the spawner
|
||||
local dummy_ore_definition = {
|
||||
hp_max = 1,
|
||||
physical = false,
|
||||
collisionbox = {0,0,0,0,0,0},
|
||||
visual = "wielditem",
|
||||
visual_size = size,
|
||||
timer = 0,
|
||||
textures={"default:"..ore_name},
|
||||
makes_footstep_sound = false,
|
||||
automatic_rotate = math.pi * -3,
|
||||
m_name = "dummy_ore"
|
||||
}
|
||||
|
||||
local ore = string.split(ore_name, "_")
|
||||
|
||||
dummy_ore_definition.on_activate = function(self)
|
||||
self.object:setvelocity({x=0, y=0, z=0})
|
||||
self.object:setacceleration({x=0, y=0, z=0})
|
||||
self.object:set_armor_groups({immortal=1})
|
||||
end
|
||||
|
||||
-- remove dummy after dug up the spawner
|
||||
dummy_ore_definition.on_step = function(self, dtime)
|
||||
self.timer = self.timer + dtime
|
||||
local n = minetest.get_node_or_nil(self.object:getpos())
|
||||
if self.timer > 2 then
|
||||
if n and n.name and n.name ~= "spawners:"..ore_name.."_spawner_active" and n.name ~= "spawners:"..ore_name.."_spawner_waiting" and n.name ~= "spawners:"..ore_name.."_spawner" then
|
||||
self.object:remove()
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
minetest.register_entity("spawners:dummy_ore_"..ore_name, dummy_ore_definition)
|
||||
|
||||
-- node spawner active
|
||||
minetest.register_node("spawners:"..ore_name.."_spawner_active", {
|
||||
description = ore_name.." spawner active",
|
||||
paramtype = "light",
|
||||
light_source = 4,
|
||||
drawtype = "allfaces",
|
||||
walkable = true,
|
||||
sounds = default.node_sound_stone_defaults(),
|
||||
damage_per_second = 4,
|
||||
sunlight_propagates = true,
|
||||
tiles = {
|
||||
{
|
||||
name = "spawners_spawner_animated.png",
|
||||
animation = {
|
||||
type = "vertical_frames",
|
||||
aspect_w = 32,
|
||||
aspect_h = 32,
|
||||
length = 2.0
|
||||
},
|
||||
}
|
||||
},
|
||||
is_ground_content = true,
|
||||
groups = {cracky=1,level=2,igniter=1,not_in_creative_inventory=1},
|
||||
drop = "spawners:"..ore_name.."_spawner",
|
||||
can_dig = can_dig,
|
||||
allow_metadata_inventory_put = allow_metadata_inventory_put,
|
||||
allow_metadata_inventory_take = allow_metadata_inventory_take,
|
||||
on_receive_fields = on_receive_fields,
|
||||
})
|
||||
|
||||
-- node spawner waiting - no stone around or no fuel
|
||||
minetest.register_node("spawners:"..ore_name.."_spawner_waiting", {
|
||||
description = ore_name.." spawner waiting",
|
||||
paramtype = "light",
|
||||
light_source = 2,
|
||||
drawtype = "allfaces",
|
||||
walkable = true,
|
||||
sounds = default.node_sound_stone_defaults(),
|
||||
sunlight_propagates = true,
|
||||
tiles = {
|
||||
{
|
||||
name = "spawners_spawner_waiting_animated.png",
|
||||
animation = {
|
||||
type = "vertical_frames",
|
||||
aspect_w = 32,
|
||||
aspect_h = 32,
|
||||
length = 2.0
|
||||
},
|
||||
}
|
||||
},
|
||||
is_ground_content = true,
|
||||
groups = {cracky=1,level=2,not_in_creative_inventory=1},
|
||||
drop = "spawners:"..ore_name.."_spawner",
|
||||
can_dig = can_dig,
|
||||
allow_metadata_inventory_put = allow_metadata_inventory_put,
|
||||
allow_metadata_inventory_take = allow_metadata_inventory_take,
|
||||
on_receive_fields = on_receive_fields,
|
||||
})
|
||||
|
||||
-- node spawner inactive (default)
|
||||
minetest.register_node("spawners:"..ore_name.."_spawner", {
|
||||
description = ore_name.." spawner",
|
||||
paramtype = "light",
|
||||
drawtype = "allfaces",
|
||||
walkable = true,
|
||||
sounds = default.node_sound_stone_defaults(),
|
||||
sunlight_propagates = true,
|
||||
tiles = {"spawners_spawner.png"},
|
||||
is_ground_content = true,
|
||||
groups = {cracky=1,level=2},
|
||||
stack_max = 1,
|
||||
on_construct = function(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
spawners.get_formspec(pos)
|
||||
pos.y = pos.y + offset
|
||||
minetest.add_entity(pos,"spawners:dummy_ore_"..ore_name)
|
||||
meta:set_string("infotext", ore[3].." ore spawner is empty")
|
||||
end,
|
||||
|
||||
can_dig = can_dig,
|
||||
|
||||
allow_metadata_inventory_put = allow_metadata_inventory_put,
|
||||
allow_metadata_inventory_take = allow_metadata_inventory_take,
|
||||
on_receive_fields = on_receive_fields,
|
||||
})
|
||||
|
||||
-- ABM
|
||||
minetest.register_abm({
|
||||
nodenames = {"spawners:"..ore_name.."_spawner_active", "spawners:"..ore_name.."_spawner_waiting"},
|
||||
interval = 5.0,
|
||||
chance = 5,
|
||||
action = function(pos, node, active_object_count, active_object_count_wider)
|
||||
|
||||
local waiting, found_node = spawners.check_node_status_ores(pos, ore_name, "default:stone")
|
||||
|
||||
|
||||
local meta = minetest.get_meta(pos)
|
||||
local inv = meta:get_inventory()
|
||||
|
||||
if found_node then
|
||||
-- make sure the right node status is shown
|
||||
if node.name ~= "spawners:"..ore_name.."_spawner_active" then
|
||||
minetest.swap_node(pos, {name="spawners:"..ore_name.."_spawner_active"})
|
||||
end
|
||||
|
||||
|
||||
-- take fuel
|
||||
local stack = inv:get_stack("fuel", 1)
|
||||
stack:take_item()
|
||||
|
||||
|
||||
inv:set_stack("fuel", 1, stack)
|
||||
|
||||
meta:set_string("infotext", ore[3].." ore spawner fuel: "..inv:get_stack("fuel", 1):get_count())
|
||||
|
||||
-- enough place to spawn more ores
|
||||
spawners.start_spawning_ores(found_node, "default:"..ore_name, sound_custom)
|
||||
|
||||
-- empty / no fuel
|
||||
if inv:is_empty("fuel") then
|
||||
minetest.swap_node(pos, {name="spawners:"..ore_name.."_spawner"})
|
||||
meta:set_string("infotext", ore[3].." ore spawner is empty.")
|
||||
|
||||
end
|
||||
else
|
||||
-- waiting status
|
||||
if node.name ~= "spawners:"..ore_name.."_spawner_waiting" then
|
||||
minetest.swap_node(pos, {name="spawners:"..ore_name.."_spawner_waiting"})
|
||||
|
||||
meta:set_string("infotext", "Waiting status - player was away or no stone around, "..ore[3].." ore spawner fuel: "..inv:get_stack("fuel", 1):get_count())
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
})
|
||||
|
||||
end
|
||||
|
||||
-- default:stone_with_gold
|
||||
spawners.create_ore("stone_with_gold", "", {x=.33,y=.33}, 0, {"default_stone.png^default_mineral_gold.png"}, "strike")
|
||||
|
||||
-- default:stone_with_iron
|
||||
spawners.create_ore("stone_with_iron", "", {x=.33,y=.33}, 0, {"default_stone.png^default_mineral_gold.png"}, "strike")
|
||||
|
||||
-- default:stone_with_copper
|
||||
spawners.create_ore("stone_with_copper", "", {x=.33,y=.33}, 0, {"default_stone.png^default_mineral_gold.png"}, "strike")
|
||||
|
||||
|
||||
-- recipes
|
||||
minetest.register_craft({
|
||||
output = "spawners:stone_with_gold_spawner",
|
||||
recipe = {
|
||||
{"default:diamondblock", "fire:flint_and_steel", "default:diamondblock"},
|
||||
{"xpanes:bar_flat", "default:goldblock", "xpanes:bar_flat"},
|
||||
{"default:diamondblock", "xpanes:bar_flat", "default:diamondblock"},
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "spawners:stone_with_iron_spawner",
|
||||
recipe = {
|
||||
{"default:diamondblock", "fire:flint_and_steel", "default:diamondblock"},
|
||||
{"xpanes:bar_flat", "default:steelblock", "xpanes:bar_flat"},
|
||||
{"default:diamondblock", "xpanes:bar_flat", "default:diamondblock"},
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "spawners:stone_with_copper_spawner",
|
||||
recipe = {
|
||||
{"default:diamondblock", "fire:flint_and_steel", "default:diamondblock"},
|
||||
{"xpanes:bar_flat", "default:copperblock", "xpanes:bar_flat"},
|
||||
{"default:diamondblock", "xpanes:bar_flat", "default:diamondblock"},
|
||||
}
|
||||
})
|
BIN
spawners_ores/textures/spawners_smoke_particle.png
Normal file
After Width: | Height: | Size: 233 B |
BIN
spawners_ores/textures/spawners_spawner.png
Normal file
After Width: | Height: | Size: 535 B |
BIN
spawners_ores/textures/spawners_spawner_animated.png
Normal file
After Width: | Height: | Size: 18 KiB |
BIN
spawners_ores/textures/spawners_spawner_normal.png
Normal file
After Width: | Height: | Size: 7.8 KiB |
BIN
spawners_ores/textures/spawners_spawner_waiting_animated.png
Normal file
After Width: | Height: | Size: 4.6 KiB |