summaryrefslogtreecommitdiff
path: root/carbone_mobs
diff options
context:
space:
mode:
authorVanessa Ezekowitz <vanessaezekowitz@gmail.com>2017-01-31 19:39:31 -0500
committerVanessa Ezekowitz <vanessaezekowitz@gmail.com>2017-01-31 19:39:31 -0500
commit39f5cba27eef35877c91291f518974f34130fcb6 (patch)
tree117a9d1b7d4ee5f78f73e1216e982c366ed9ecc6 /carbone_mobs
parent2922421f4a88e56a0a1c819f62bf2bc287835388 (diff)
downloaddreambuilder_modpack-39f5cba27eef35877c91291f518974f34130fcb6.tar
dreambuilder_modpack-39f5cba27eef35877c91291f518974f34130fcb6.tar.gz
dreambuilder_modpack-39f5cba27eef35877c91291f518974f34130fcb6.tar.bz2
dreambuilder_modpack-39f5cba27eef35877c91291f518974f34130fcb6.tar.xz
dreambuilder_modpack-39f5cba27eef35877c91291f518974f34130fcb6.zip
Huge update - lots of mods:
areas, biome_lib, blox, bobblocks, boost_cart, homedecor, mobs, coloredwood, ilights, inbox, item_tweaks, moreblocks, moreores, pipeworks, plasticbox, signs_lib, stainedglass, roads, unifieddyes, vines, worldedit, xban2, maybe some others I didn't think about ;-)
Diffstat (limited to 'carbone_mobs')
-rw-r--r--carbone_mobs/README.txt19
-rw-r--r--carbone_mobs/api.lua66
-rw-r--r--carbone_mobs/init.lua3
3 files changed, 58 insertions, 30 deletions
diff --git a/carbone_mobs/README.txt b/carbone_mobs/README.txt
index a74e6ff..b7bdc0d 100644
--- a/carbone_mobs/README.txt
+++ b/carbone_mobs/README.txt
@@ -16,9 +16,28 @@ http://wiki.minetest.com/wiki/Installing_Mods
How to use the mod:
See https://github.com/PilzAdam/mobs/wiki
+This mod can be configured via following minetest.conf variables:
+( reminder: minetest.conf lines starting with "#" are comments )
+
+* display_mob_spawn = true -> show you a message in the chat when a mob spawns. see https://github.com/PilzAdam/mobs/wiki
+* only_peaceful_mobs = true -> "When you add only_peaceful_mobs = true to minetest.conf then all hostile mobs will despawn."
+ "They do spawn, but they immediately despawn." (see https://forum.minetest.net/viewtopic.php?id=551)
+
+So instead you can directly use this to avoid false-alarming spawn messages...
+* spawn_friendly_mobs = true -> spawn friendly mobs (sheep, rat)
+* spawn_hostile_mobs = true -> spawn hostile mobs
+
+
For developers:
The API documentation is moved to https://github.com/PilzAdam/mobs/wiki/API
+Some internal details:
+
+* armor: lower values means better armor, means you need a better weapon to hurt it.
+ see e.g. https://github.com/PilzAdam/mobs/wiki/Dungeon-Master:
+ stone sword is OK to attack against armor value of 60.
+
+
License:
Sourcecode: WTFPL (see below)
Grahpics: WTFPL (see below)
diff --git a/carbone_mobs/api.lua b/carbone_mobs/api.lua
index 227b0c0..675adc8 100644
--- a/carbone_mobs/api.lua
+++ b/carbone_mobs/api.lua
@@ -3,6 +3,12 @@ local monster_damage = minetest.setting_get("monster_damage_factor") or 1.0
carbone_mobs = {}
function carbone_mobs:register_mob(name, def)
+
+ -- jump = true as default
+ local is_jumping = true
+ if def.jump ~= nil then is_jumping = def.jump end
+
+ -- see http://dev.minetest.net/register_entity
minetest.register_entity(name, {
hp_max = def.hp_max,
physical = true,
@@ -32,7 +38,7 @@ function carbone_mobs:register_mob(name, def)
sounds = def.sounds,
animation = def.animation,
follow = def.follow,
- jump = def.jump or true,
+ jump = is_jumping,
timer = 0,
env_damage_timer = 0, -- only if state = "attack"
@@ -115,10 +121,10 @@ function carbone_mobs:register_mob(name, def)
end
end
end,
-
- on_step = function(self, dtime)
-
+ -- see http://dev.minetest.net/LuaEntitySAO
+ -- Callback method called every server tick.
+ on_step = function(self, dtime)
self.lifetimer = self.lifetimer - dtime
if self.lifetimer <= 0 and not self.tamed then
local player_count = 0
@@ -436,7 +442,7 @@ function carbone_mobs:register_mob(name, def)
obj:setvelocity(vec)
end
end
- end,
+ end, -- on_step
on_activate = function(self, staticdata, dtime_s)
self.object:set_armor_groups({fleshy = self.armor})
@@ -460,7 +466,7 @@ function carbone_mobs:register_mob(name, def)
minetest.log("action", "A mob with " .. tostring(hp) .. " HP despawned at " .. minetest.pos_to_string(pos) .. " on activation.")
self.object:remove()
end
- end,
+ end, -- on_activate
get_staticdata = function(self)
local tmp = {
@@ -468,34 +474,34 @@ function carbone_mobs:register_mob(name, def)
tamed = self.tamed,
}
return minetest.serialize(tmp)
- end,
+ end, -- get_staticdata
on_punch = function(self, hitter)
- local hp = self.object:get_hp()
- if hp >= 1 then
- minetest.sound_play("player_damage", {object = self.object, gain = 0.25})
- minetest.sound_play("hit", {pos = hitter:getpos(), gain = 0.4})
- end
- local y = self.object:getvelocity().y
- if y <= 0 then
- self.object:setvelocity({x = 0, y = y + 4.5, z = 0})
- end
- if hp <= 0 then
- if hitter and hitter:is_player() and hitter:get_inventory() then
- local pos = self.object:getpos()
- minetest.sound_play("player_death", {object = self.object, gain = 0.4})
- minetest.sound_play("hit_death", {pos = hitter:getpos(), gain = 0.4})
- for _,drop in ipairs(self.drops) do
- if math.random(1, drop.chance) == 1 then
- hitter:get_inventory():add_item("main", ItemStack(drop.name .. " " .. math.random(drop.min, drop.max)))
- end
- end
- end
- end
- end,
+ local hp = self.object:get_hp()
+ if hp >= 1 then
+ minetest.sound_play("player_damage", {object = self.object, gain = 0.25})
+ minetest.sound_play("hit", {pos = hitter:getpos(), gain = 0.4})
+ end
+ local y = self.object:getvelocity().y
+ if y <= 0 then
+ self.object:setvelocity({x = 0, y = y + 4.5, z = 0})
+ end
+ if hp <= 0 then
+ if hitter and hitter:is_player() and hitter:get_inventory() then
+ local pos = self.object:getpos()
+ minetest.sound_play("player_death", {object = self.object, gain = 0.4})
+ minetest.sound_play("hit_death", {pos = hitter:getpos(), gain = 0.4})
+ for _,drop in ipairs(self.drops) do
+ if math.random(1, drop.chance) == 1 then
+ hitter:get_inventory():add_item("main", ItemStack(drop.name .. " " .. math.random(drop.min, drop.max)))
+ end
+ end
+ end
+ end -- if hp <= 0
+ end, -- on_punch
})
-end
+end --function carbone_mobs:register_mob(name, def)
carbone_mobs.spawning_mobs = {}
function carbone_mobs:register_spawn(name, description, nodes, max_light, min_light, chance, active_object_count, max_height, spawn_func)
diff --git a/carbone_mobs/init.lua b/carbone_mobs/init.lua
index a57fb4b..f12f105 100644
--- a/carbone_mobs/init.lua
+++ b/carbone_mobs/init.lua
@@ -1,6 +1,9 @@
dofile(minetest.get_modpath("carbone_mobs").."/api.lua")
+-- Minetest states since 2013 to use lua 5.1 (see http://dev.minetest.net/Lua , https://www.lua.org/manual/5.1/ )
+
-- Ensure the correct active_block_range value is used (for performance and spawning):
+-- see http://dev.minetest.net/minetest.register_abm
minetest.setting_set("active_block_range", 1)
carbone_mobs:register_mob("carbone_mobs:dirt_monster", {