1
0
mirror of https://github.com/sys4-fr/server-nalc.git synced 2024-12-24 17:50:37 +01:00

Added cow dung

- O_o?
This commit is contained in:
LeMagnesium 2015-05-18 18:49:26 +02:00
parent 26b6b69f28
commit 83984a6941
4 changed files with 94 additions and 45 deletions

View File

@ -61,10 +61,7 @@ lifetimer = def.lifetimer or 600,
blood_texture = def.blood_texture or "mobs_blood.png",
shoot_offset = def.shoot_offset or 0,
floats = def.floats or 1, -- floats in water by default
replace_rate = def.replace_rate,
replace_what = def.replace_what,
replace_with = def.replace_with,
replace_offset = def.replace_offset or 0,
replacements = def.replacements or {},
timer = 0,
env_damage_timer = 0, -- only if state = "attack"
attack = {player=nil, dist=nil},
@ -180,16 +177,28 @@ lifetimer = def.lifetimer or 600,
end
-- check for mob drop/replace (used for chicken egg and sheep eating grass/wheat)
if self.replace_rate
and math.random(1,self.replace_rate) == 1
and self.child == false then
local pos = self.object:getpos()
pos.y = pos.y + self.replace_offset
if #minetest.find_nodes_in_area(pos,pos,self.replace_what) > 0
and self.object:getvelocity().y == 0
and self.replace_what then
--and self.state == "stand" then
minetest.set_node(pos, {name = self.replace_with})
--[[
old fields :
replace_rate = def.replace_rate,
replace_what = def.replace_what,
replace_with = def.replace_with,
replace_offset = def.replace_offset or 0,
]]--
for _, fields in pairs(self.replacements) do
if fields.replace_rate
and math.random(1,fields.replace_rate) == 1
and self.child == false then
fields.replace_offset = fields.replace_offset or 0
local pos = self.object:getpos()
pos.y = pos.y + fields.replace_offset
if #minetest.find_nodes_in_area(pos,pos,fields.replace_what) > 0
and self.object:getvelocity().y == 0
and fields.replace_what then
minetest.set_node(pos, {name = fields.replace_with})
end
end
end

View File

@ -56,9 +56,13 @@ mobs:register_mob("mobs:chicken", {
follow = "farming:seed_wheat",
view_range = 8,
-- replace air with egg (lay)
replace_rate = 2000,
replace_what = {"air"},
replace_with = "mobs:egg",
replacements = {
{
replace_rate = 2000,
replace_what = {"air"},
replace_with = "mobs:egg",
}
},
-- right click to pick up chicken
on_rightclick = function(self, clicker)
local tool = clicker:get_wielded_item()

View File

@ -53,9 +53,19 @@ mobs:register_mob("mobs:cow", {
-- follows wheat
follow = "farming:wheat", view_range = 8,
-- replace grass/wheat with air (eat)
replace_rate = 50,
replace_what = {"default:grass_3", "default:grass_4", "default:grass_5", "farming:wheat_8"},
replace_with = "air",
replacements = {
{
replace_rate = 50,
replace_what = {"default:grass_3", "default:grass_4",
"default:grass_5", "farming:wheat_8"},
replace_with = "air",
},
{
replace_rate = 2000,
replace_what = {"air"},
replace_with = "mobs:dung",
}
},
-- right-click cow with empty bucket to get milk, then feed 8 wheat to replenish milk
on_rightclick = function(self, clicker)
local tool = clicker:get_wielded_item()
@ -169,3 +179,29 @@ minetest.register_craft({
{'mobs:cheeseblock'},
}
})
-- Dung
-- O_o?
minetest.register_node("mobs:dung", {
description = "Cow dung",
tiles = {"mobs_dung.png"},
inventory_image = "mobs_dung.png",
visual_scale = 0.7,
drawtype = "plantlike",
wield_image = "mobs_dung.png",
paramtype = "light",
walkable = false,
is_ground_content = true,
sunlight_propagates = true,
selection_box = {
type = "fixed",
fixed = {-0.2, -0.5, -0.2, 0.2, 0, 0.2}
},
groups = {snappy=2, dig_immediate=3},
after_place_node = function(pos, placer, itemstack)
if placer:is_player() then
minetest.set_node(pos, {name="mobs:dung", param2=1})
end
end
})

Binary file not shown.

After

Width:  |  Height:  |  Size: 635 B