update mobs mod
@ -28,6 +28,9 @@ This mod contains the following additions:
|
|||||||
|
|
||||||
Changelog:
|
Changelog:
|
||||||
|
|
||||||
|
1.24- Added feature where certain animals run away when punched (runaway = true in mob definition)
|
||||||
|
1.23- Added mob spawner block for admin to setup spawners in-game (place and right click to enter settings)
|
||||||
|
1.22- Added ability to name tamed animals and npc using nametags, also npc will attack anyone who punches them apart from owner
|
||||||
1.21- Added some more error checking to reduce serialize.h error and added height checks for falling off cliffs (thanks cmdskp)
|
1.21- Added some more error checking to reduce serialize.h error and added height checks for falling off cliffs (thanks cmdskp)
|
||||||
1.20- Error checking added to remove bad mobs, out of map limit mobs and stop serialize.h error
|
1.20- Error checking added to remove bad mobs, out of map limit mobs and stop serialize.h error
|
||||||
1.19- Chickens now drop egg items instead of placing the egg, also throwing eggs result in 1/8 chance of spawning chick
|
1.19- Chickens now drop egg items instead of placing the egg, also throwing eggs result in 1/8 chance of spawning chick
|
||||||
|
@ -8,7 +8,9 @@ mobs:register_mob("mobs:bunny", {
|
|||||||
passive = true,
|
passive = true,
|
||||||
reach = 1,
|
reach = 1,
|
||||||
-- health & armor
|
-- health & armor
|
||||||
hp_min = 3, hp_max = 6, armor = 200,
|
hp_min = 3,
|
||||||
|
hp_max = 6,
|
||||||
|
armor = 200,
|
||||||
-- textures and model
|
-- textures and model
|
||||||
collisionbox = {-0.268, -0.5, -0.268, 0.268, 0.167, 0.268},
|
collisionbox = {-0.268, -0.5, -0.268, 0.268, 0.167, 0.268},
|
||||||
visual = "mesh",
|
visual = "mesh",
|
||||||
@ -18,13 +20,14 @@ mobs:register_mob("mobs:bunny", {
|
|||||||
{"mobs_bunny_grey.png"},
|
{"mobs_bunny_grey.png"},
|
||||||
{"mobs_bunny_brown.png"},
|
{"mobs_bunny_brown.png"},
|
||||||
{"mobs_bunny_white.png"},
|
{"mobs_bunny_white.png"},
|
||||||
{"mobs_bunny_evil.png"},
|
|
||||||
},
|
},
|
||||||
-- sounds
|
-- sounds
|
||||||
sounds = {},
|
sounds = {},
|
||||||
makes_footstep_sound = false,
|
makes_footstep_sound = false,
|
||||||
-- speed and jump
|
-- speed and jump
|
||||||
walk_velocity = 1, run_velocity = 2,
|
walk_velocity = 1,
|
||||||
|
run_velocity = 2,
|
||||||
|
runaway = true,
|
||||||
jump = true,
|
jump = true,
|
||||||
-- drops meat when dead
|
-- drops meat when dead
|
||||||
drops = {
|
drops = {
|
||||||
@ -55,25 +58,35 @@ mobs:register_mob("mobs:bunny", {
|
|||||||
replace_with = "air",
|
replace_with = "air",
|
||||||
-- right click to pick up rabbit
|
-- right click to pick up rabbit
|
||||||
on_rightclick = function(self, clicker)
|
on_rightclick = function(self, clicker)
|
||||||
if not mobs:feed_tame(self, clicker, 4, true, true) then
|
|
||||||
-- Monty Python tribute
|
-- feed or tame
|
||||||
local item = clicker:get_wielded_item()
|
if mobs:feed_tame(self, clicker, 4, true, true) then
|
||||||
if item:get_name() == "mobs:lava_orb" then
|
return
|
||||||
if not minetest.setting_getbool("creative_mode") then
|
end
|
||||||
item:take_item()
|
|
||||||
clicker:set_wielded_item(item)
|
-- Monty Python tribute
|
||||||
end
|
local item = clicker:get_wielded_item()
|
||||||
self.object:set_properties({
|
|
||||||
textures = {"mobs_bunny_evil.png"},
|
if item:get_name() == "mobs:lava_orb" then
|
||||||
})
|
|
||||||
self.type = "monster"
|
if not minetest.setting_getbool("creative_mode") then
|
||||||
self.object:set_hp(20)
|
item:take_item()
|
||||||
return
|
clicker:set_wielded_item(item)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
self.object:set_properties({
|
||||||
|
textures = {"mobs_bunny_evil.png"},
|
||||||
|
})
|
||||||
|
|
||||||
|
self.type = "monster"
|
||||||
|
self.object:set_hp(20)
|
||||||
|
|
||||||
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
mobs:capture_mob(self, clicker, 30, 50, 80, false, nil)
|
mobs:capture_mob(self, clicker, 30, 50, 80, false, nil)
|
||||||
end,
|
end,
|
||||||
|
|
||||||
attack_type = "dogfight",
|
attack_type = "dogfight",
|
||||||
damage = 5,
|
damage = 5,
|
||||||
})
|
})
|
||||||
|
@ -33,6 +33,8 @@ mobs:register_mob("mobs:chicken", {
|
|||||||
},
|
},
|
||||||
-- speed and jump
|
-- speed and jump
|
||||||
walk_velocity = 1,
|
walk_velocity = 1,
|
||||||
|
run_velocity = 3,
|
||||||
|
runaway = true,
|
||||||
jump = true,
|
jump = true,
|
||||||
-- drops raw chicken when dead
|
-- drops raw chicken when dead
|
||||||
drops = {
|
drops = {
|
||||||
@ -59,7 +61,9 @@ mobs:register_mob("mobs:chicken", {
|
|||||||
view_range = 5,
|
view_range = 5,
|
||||||
|
|
||||||
on_rightclick = function(self, clicker)
|
on_rightclick = function(self, clicker)
|
||||||
mobs:feed_tame(self, clicker, 8, true, true)
|
if mobs:feed_tame(self, clicker, 8, true, true) then
|
||||||
|
return
|
||||||
|
end
|
||||||
mobs:capture_mob(self, clicker, 30, 50, 80, false, nil)
|
mobs:capture_mob(self, clicker, 30, 50, 80, false, nil)
|
||||||
end,
|
end,
|
||||||
|
|
||||||
@ -137,12 +141,12 @@ mobs:register_arrow("mobs:egg_entity", {
|
|||||||
end
|
end
|
||||||
})
|
})
|
||||||
|
|
||||||
-- snowball throwing item
|
-- egg throwing item
|
||||||
|
|
||||||
local egg_GRAVITY = 9
|
local egg_GRAVITY = 9
|
||||||
local egg_VELOCITY = 19
|
local egg_VELOCITY = 19
|
||||||
|
|
||||||
-- shoot snowball
|
-- shoot egg
|
||||||
local mobs_shoot_egg = function (item, player, pointed_thing)
|
local mobs_shoot_egg = function (item, player, pointed_thing)
|
||||||
local playerpos = player:getpos()
|
local playerpos = player:getpos()
|
||||||
minetest.sound_play("default_place_node_hard", {
|
minetest.sound_play("default_place_node_hard", {
|
||||||
|
@ -66,28 +66,45 @@ mobs:register_mob("mobs:cow", {
|
|||||||
replace_with = "air",
|
replace_with = "air",
|
||||||
fear_height = 2,
|
fear_height = 2,
|
||||||
on_rightclick = function(self, clicker)
|
on_rightclick = function(self, clicker)
|
||||||
if not mobs:feed_tame(self, clicker, 8, true, true) then
|
|
||||||
local tool = clicker:get_wielded_item()
|
|
||||||
|
|
||||||
-- milk cow with empty bucket
|
-- feed or tame
|
||||||
if tool:get_name() == "bucket:bucket_empty" then
|
if mobs:feed_tame(self, clicker, 8, true, true) then
|
||||||
if self.gotten == true
|
return
|
||||||
or self.child == true then
|
end
|
||||||
return
|
|
||||||
end
|
local tool = clicker:get_wielded_item()
|
||||||
local inv = clicker:get_inventory()
|
|
||||||
inv:remove_item("main", "bucket:bucket_empty")
|
-- milk cow with empty bucket
|
||||||
if inv:room_for_item("main", {name = "mobs:bucket_milk"}) then
|
if tool:get_name() == "bucket:bucket_empty" then
|
||||||
clicker:get_inventory():add_item("main", "mobs:bucket_milk")
|
|
||||||
else
|
--if self.gotten == true
|
||||||
local pos = self.object:getpos()
|
if self.child == true then
|
||||||
pos.y = pos.y + 0.5
|
|
||||||
minetest.add_item(pos, {name = "mobs:bucket_milk"})
|
|
||||||
end
|
|
||||||
self.gotten = true -- milked
|
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if self.gotten == true then
|
||||||
|
minetest.chat_send_player(clicker:get_player_name(),
|
||||||
|
"Cow already milked!")
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
local inv = clicker:get_inventory()
|
||||||
|
|
||||||
|
inv:remove_item("main", "bucket:bucket_empty")
|
||||||
|
|
||||||
|
if inv:room_for_item("main", {name = "mobs:bucket_milk"}) then
|
||||||
|
clicker:get_inventory():add_item("main", "mobs:bucket_milk")
|
||||||
|
else
|
||||||
|
local pos = self.object:getpos()
|
||||||
|
pos.y = pos.y + 0.5
|
||||||
|
minetest.add_item(pos, {name = "mobs:bucket_milk"})
|
||||||
|
end
|
||||||
|
|
||||||
|
self.gotten = true -- milked
|
||||||
|
|
||||||
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
mobs:capture_mob(self, clicker, 0, 5, 60, false, nil)
|
mobs:capture_mob(self, clicker, 0, 5, 60, false, nil)
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
@ -1,3 +1,15 @@
|
|||||||
|
-- nametag
|
||||||
|
minetest.register_craftitem("mobs:nametag", {
|
||||||
|
description = "Nametag",
|
||||||
|
inventory_image = "mobs_nametag.png",
|
||||||
|
})
|
||||||
|
|
||||||
|
core.register_craft({
|
||||||
|
type = "shapeless",
|
||||||
|
output = "mobs:nametag",
|
||||||
|
recipe = {"default:paper", "dye:black", "farming:string"},
|
||||||
|
})
|
||||||
|
|
||||||
-- leather
|
-- leather
|
||||||
minetest.register_craftitem("mobs:leather", {
|
minetest.register_craftitem("mobs:leather", {
|
||||||
description = "Leather",
|
description = "Leather",
|
||||||
|
@ -1,9 +1,6 @@
|
|||||||
|
|
||||||
-- Dungeon Master by PilzAdam
|
-- Dungeon Master by PilzAdam
|
||||||
|
|
||||||
-- Node which cannot be destroyed by DungeonMasters' fireballs
|
|
||||||
local excluded = {"nether:netherrack","default:obsidian_glass","default:obsidian", "default:obsidian_cooled", "default:bedrock", "doors:door_steel_b_1", "doors:door_steel_t_1", "doors:door_steel_b_2", "doors:door_steel_t_2","default:chest_locked"}
|
|
||||||
|
|
||||||
mobs:register_mob("mobs:dungeon_master", {
|
mobs:register_mob("mobs:dungeon_master", {
|
||||||
-- animal, monster, npc, barbarian
|
-- animal, monster, npc, barbarian
|
||||||
type = "monster",
|
type = "monster",
|
||||||
@ -100,7 +97,7 @@ mobs:register_arrow("mobs:fireball", {
|
|||||||
}, nil)
|
}, nil)
|
||||||
end,
|
end,
|
||||||
|
|
||||||
-- node hit, bursts into flame (cannot blast through obsidian or protection redo mod items)
|
-- node hit, bursts into flame
|
||||||
hit_node = function(self, pos, node)
|
hit_node = function(self, pos, node)
|
||||||
mobs:explosion(pos, 1, 1, 0)
|
mobs:explosion(pos, 1, 1, 0)
|
||||||
end
|
end
|
||||||
|
@ -8,6 +8,7 @@ mobs:register_mob("mobs:goat", {
|
|||||||
passive = false,
|
passive = false,
|
||||||
group_attack = true,
|
group_attack = true,
|
||||||
attack_type = "dogfight",
|
attack_type = "dogfight",
|
||||||
|
reach = 2,
|
||||||
damage = 4,
|
damage = 4,
|
||||||
-- health & armor
|
-- health & armor
|
||||||
hp_min = 15,
|
hp_min = 15,
|
||||||
|
@ -62,6 +62,9 @@ dofile(path.."/creeper.lua")
|
|||||||
-- Mob Items
|
-- Mob Items
|
||||||
dofile(path.."/crafts.lua")
|
dofile(path.."/crafts.lua")
|
||||||
|
|
||||||
|
-- Spawner
|
||||||
|
dofile(path.."/spawner.lua")
|
||||||
|
|
||||||
-- Mob menu spawner special MFF
|
-- Mob menu spawner special MFF
|
||||||
dofile(path.."/mff_menu.lua")
|
dofile(path.."/mff_menu.lua")
|
||||||
|
|
||||||
|
@ -7,7 +7,9 @@ mobs:register_mob("mobs:kitten", {
|
|||||||
-- is it aggressive
|
-- is it aggressive
|
||||||
passive = true,
|
passive = true,
|
||||||
-- health & armor
|
-- health & armor
|
||||||
hp_min = 4, hp_max = 8, armor = 200,
|
hp_min = 4,
|
||||||
|
hp_max = 8,
|
||||||
|
armor = 200,
|
||||||
-- textures and model
|
-- textures and model
|
||||||
collisionbox = {-0.3, -0.3, -0.3, 0.3, 0.1, 0.3},
|
collisionbox = {-0.3, -0.3, -0.3, 0.3, 0.1, 0.3},
|
||||||
visual = "mesh",
|
visual = "mesh",
|
||||||
@ -27,6 +29,8 @@ mobs:register_mob("mobs:kitten", {
|
|||||||
},
|
},
|
||||||
-- speed and jump
|
-- speed and jump
|
||||||
walk_velocity = 0.6,
|
walk_velocity = 0.6,
|
||||||
|
run_velocity = 2,
|
||||||
|
runaway = true,
|
||||||
jump = false,
|
jump = false,
|
||||||
-- drops string
|
-- drops string
|
||||||
drops = {
|
drops = {
|
||||||
@ -50,7 +54,9 @@ mobs:register_mob("mobs:kitten", {
|
|||||||
view_range = 10,
|
view_range = 10,
|
||||||
-- feed with raw fish to tame or right click to pick up
|
-- feed with raw fish to tame or right click to pick up
|
||||||
on_rightclick = function(self, clicker)
|
on_rightclick = function(self, clicker)
|
||||||
mobs:feed_tame(self, clicker, 4, true, true)
|
if mobs:feed_tame(self, clicker, 4, true, true) then
|
||||||
|
return
|
||||||
|
end
|
||||||
mobs:capture_mob(self, clicker, 50, 50, 90, false, nil)
|
mobs:capture_mob(self, clicker, 50, 50, 90, false, nil)
|
||||||
end
|
end
|
||||||
})
|
})
|
||||||
|
0
mods/mobs/models/mobs_ent.x
Normal file → Executable file
0
mods/mobs/models/mobs_pig.b3d
Normal file → Executable file
@ -8,7 +8,6 @@ mobs.npc_drops = { "farming:meat", "farming:donut", "farming:bread", "default:a
|
|||||||
"default:cobble", "default:gravel", "default:clay_lump", "default:sand", "default:dirt_with_grass",
|
"default:cobble", "default:gravel", "default:clay_lump", "default:sand", "default:dirt_with_grass",
|
||||||
"default:dirt", "default:chest", "default:torch"}
|
"default:dirt", "default:chest", "default:torch"}
|
||||||
|
|
||||||
mobs.npc_max_hp = 20
|
|
||||||
|
|
||||||
mobs:register_mob("mobs:npc", {
|
mobs:register_mob("mobs:npc", {
|
||||||
-- animal, monster, npc
|
-- animal, monster, npc
|
||||||
@ -20,7 +19,9 @@ mobs:register_mob("mobs:npc", {
|
|||||||
attack_type = "dogfight",
|
attack_type = "dogfight",
|
||||||
attacks_monsters = true,
|
attacks_monsters = true,
|
||||||
-- health & armor
|
-- health & armor
|
||||||
hp_min = 20, hp_max = 20, armor = 100,
|
hp_min = 20,
|
||||||
|
hp_max = 20,
|
||||||
|
armor = 100,
|
||||||
-- textures and model
|
-- textures and model
|
||||||
collisionbox = {-0.35,-1.0,-0.35, 0.35,0.8,0.35},
|
collisionbox = {-0.35,-1.0,-0.35, 0.35,0.8,0.35},
|
||||||
visual = "mesh",
|
visual = "mesh",
|
||||||
@ -106,6 +107,7 @@ mobs:register_mob("mobs:npc", {
|
|||||||
item:take_item()
|
item:take_item()
|
||||||
clicker:set_wielded_item(item)
|
clicker:set_wielded_item(item)
|
||||||
end
|
end
|
||||||
|
|
||||||
local pos = self.object:getpos()
|
local pos = self.object:getpos()
|
||||||
pos.y = pos.y + 0.5
|
pos.y = pos.y + 0.5
|
||||||
minetest.add_item(pos, {
|
minetest.add_item(pos, {
|
||||||
@ -122,6 +124,7 @@ mobs:register_mob("mobs:npc", {
|
|||||||
end
|
end
|
||||||
mobs:capture_mob(self, clicker, 0, 5, 80, false, nil)
|
mobs:capture_mob(self, clicker, 0, 5, 80, false, nil)
|
||||||
end
|
end
|
||||||
|
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -44,6 +44,7 @@ mobs:register_mob("mobs:oerkki", {
|
|||||||
water_damage = 2,
|
water_damage = 2,
|
||||||
lava_damage = 4,
|
lava_damage = 4,
|
||||||
light_damage = 1,
|
light_damage = 1,
|
||||||
|
fear_height = 3,
|
||||||
-- model animation
|
-- model animation
|
||||||
animation = {
|
animation = {
|
||||||
stand_start = 0,
|
stand_start = 0,
|
||||||
|
@ -26,6 +26,8 @@ mobs:register_mob("mobs:rat", {
|
|||||||
},
|
},
|
||||||
-- speed and jump
|
-- speed and jump
|
||||||
walk_velocity = 1,
|
walk_velocity = 1,
|
||||||
|
run_velocity = 2,
|
||||||
|
runaway = true,
|
||||||
jump = true,
|
jump = true,
|
||||||
-- no drops
|
-- no drops
|
||||||
drops = {},
|
drops = {},
|
||||||
|
@ -6,7 +6,7 @@ local all_colours = {
|
|||||||
|
|
||||||
-- Sheep by PilzAdam
|
-- Sheep by PilzAdam
|
||||||
|
|
||||||
for _, col in ipairs(all_colours) do
|
for _, col in pairs(all_colours) do
|
||||||
|
|
||||||
mobs:register_mob("mobs:sheep_"..col, {
|
mobs:register_mob("mobs:sheep_"..col, {
|
||||||
-- animal, monster, npc, barbarian
|
-- animal, monster, npc, barbarian
|
||||||
@ -36,6 +36,7 @@ for _, col in ipairs(all_colours) do
|
|||||||
-- speed and jump
|
-- speed and jump
|
||||||
walk_velocity = 1,
|
walk_velocity = 1,
|
||||||
run_velocity = 2,
|
run_velocity = 2,
|
||||||
|
runaway = true,
|
||||||
jump = true,
|
jump = true,
|
||||||
-- drops raw meat and woll of its color when dead
|
-- drops raw meat and woll of its color when dead
|
||||||
drops = {
|
drops = {
|
||||||
@ -117,7 +118,10 @@ for _, col in ipairs(all_colours) do
|
|||||||
|
|
||||||
--are we coloring?
|
--are we coloring?
|
||||||
if itemname:find("dye:") then
|
if itemname:find("dye:") then
|
||||||
if self.gotten == false and self.child == false and self.tamed == true and name == self.owner then
|
if self.gotten == false
|
||||||
|
and self.child == false
|
||||||
|
and self.tamed == true
|
||||||
|
and name == self.owner then
|
||||||
local col = string.split(itemname,":")[2]
|
local col = string.split(itemname,":")[2]
|
||||||
for _,c in pairs(all_colours) do
|
for _,c in pairs(all_colours) do
|
||||||
if c == col then
|
if c == col then
|
||||||
@ -185,4 +189,4 @@ minetest.register_entity("mobs:sheep", {
|
|||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
|
|
||||||
})
|
})
|
||||||
|
0
mods/mobs/sounds/default_punch2.ogg
Normal file → Executable file
0
mods/mobs/sounds/mobs_die_yell.ogg
Normal file → Executable file
0
mods/mobs/sounds/mobs_yeti_death.ogg
Normal file → Executable file
127
mods/mobs/spawner.lua
Executable file
@ -0,0 +1,127 @@
|
|||||||
|
-- mob spawner
|
||||||
|
|
||||||
|
local spawner_default = "mobs:pig 10 15 0"
|
||||||
|
|
||||||
|
minetest.register_node("mobs:spawner", {
|
||||||
|
tiles = {"mob_spawner.png"},
|
||||||
|
drawtype = "glasslike",
|
||||||
|
paramtype = "light",
|
||||||
|
walkable = true,
|
||||||
|
description = "Mob Spawner",
|
||||||
|
groups = {cracky = 1},
|
||||||
|
|
||||||
|
on_construct = function(pos)
|
||||||
|
|
||||||
|
local meta = minetest.get_meta(pos)
|
||||||
|
|
||||||
|
-- text entry formspec
|
||||||
|
meta:set_string("formspec", "field[text;mob_name min_light max_light amount;${command}]")
|
||||||
|
meta:set_string("infotext", "Spawner Not Active (enter settings)")
|
||||||
|
meta:set_string("command", spawner_default)
|
||||||
|
end,
|
||||||
|
|
||||||
|
on_right_click = function(pos, placer)
|
||||||
|
local meta = minetest.get_meta(pos)
|
||||||
|
end,
|
||||||
|
|
||||||
|
on_receive_fields = function(pos, formname, fields, sender)
|
||||||
|
|
||||||
|
if not fields.text or fields.text == "" then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
local meta = minetest.get_meta(pos)
|
||||||
|
local comm = fields.text:split(" ")
|
||||||
|
local name = sender:get_player_name()
|
||||||
|
|
||||||
|
if minetest.is_protected(pos, name) then
|
||||||
|
minetest.record_protection_violation(pos, name)
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
local mob = comm[1]
|
||||||
|
local mlig = tonumber(comm[2])
|
||||||
|
local xlig = tonumber(comm[3])
|
||||||
|
local num = tonumber(comm[4])
|
||||||
|
|
||||||
|
if mob and mob ~= ""
|
||||||
|
and num and num >= 0 and num <= 10
|
||||||
|
and mlig and mlig >= 0 and mlig <= 15
|
||||||
|
and xlig and xlig >= 0 and xlig <= 15 then
|
||||||
|
|
||||||
|
meta:set_string("command", fields.text)
|
||||||
|
meta:set_string("infotext", "Spawner Active (" .. mob .. ")")
|
||||||
|
|
||||||
|
else
|
||||||
|
minetest.chat_send_player(name, "Mob Spawner settings failed!")
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
|
||||||
|
-- spawner abm
|
||||||
|
minetest.register_abm({
|
||||||
|
nodenames = {"mobs:spawner"},
|
||||||
|
interval = 10,
|
||||||
|
chance = 4,
|
||||||
|
catch_up = false,
|
||||||
|
|
||||||
|
action = function(pos, node, active_object_count, active_object_count_wider)
|
||||||
|
|
||||||
|
-- check objects inside 9x9 area around spawner
|
||||||
|
local objs = minetest.get_objects_inside_radius(pos, 9)
|
||||||
|
|
||||||
|
-- get meta and command
|
||||||
|
local meta = minetest.get_meta(pos)
|
||||||
|
local comm = meta:get_string("command"):split(" ")
|
||||||
|
|
||||||
|
-- get settings from command
|
||||||
|
local mob = comm[1]
|
||||||
|
local mlig = tonumber(comm[2])
|
||||||
|
local xlig = tonumber(comm[3])
|
||||||
|
local num = tonumber(comm[4])
|
||||||
|
|
||||||
|
-- if amount is 0 then do nothing
|
||||||
|
if num == 0 then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
local count = 0
|
||||||
|
local ent = nil
|
||||||
|
|
||||||
|
-- count objects of same type in area
|
||||||
|
for k, obj in pairs(objs) do
|
||||||
|
|
||||||
|
ent = obj:get_luaentity()
|
||||||
|
|
||||||
|
if ent and ent.name == mob then
|
||||||
|
count = count + 1
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- is there too many of same type?
|
||||||
|
if count >= num then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
-- find air blocks within 5 nodes of spawner
|
||||||
|
local air = minetest.find_nodes_in_area(
|
||||||
|
{x = pos.x - 5, y = pos.y, z = pos.z - 5},
|
||||||
|
{x = pos.x + 5, y = pos.y, z = pos.z + 5},
|
||||||
|
{"air"})
|
||||||
|
|
||||||
|
-- spawn in random air block
|
||||||
|
if air and #air > 0 then
|
||||||
|
|
||||||
|
local pos2 = air[math.random(#air)]
|
||||||
|
local lig = minetest.get_node_light(pos2)
|
||||||
|
|
||||||
|
pos2.y = pos2.y + 0.5
|
||||||
|
|
||||||
|
-- only if light levels are within range
|
||||||
|
if lig and lig >= mlig and lig <= xlig then
|
||||||
|
minetest.add_entity(pos2, mob)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
})
|
BIN
mods/mobs/textures/mob_spawner.png
Executable file
After Width: | Height: | Size: 108 B |
0
mods/mobs/textures/mobs_ent.png
Normal file → Executable file
Before Width: | Height: | Size: 36 KiB After Width: | Height: | Size: 36 KiB |
BIN
mods/mobs/textures/mobs_nametag.png
Executable file
After Width: | Height: | Size: 247 B |
0
mods/mobs/textures/mobs_pig_inv.png
Normal file → Executable file
Before Width: | Height: | Size: 892 B After Width: | Height: | Size: 892 B |
0
mods/mobs/textures/mobs_pig_pink.png
Normal file → Executable file
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 1.3 KiB |
Before Width: | Height: | Size: 1.7 KiB |