Add "barn" mod from "mobf_core" modpack.

This commit is contained in:
AntumDeluge 2016-08-01 01:50:36 -07:00
parent bc8d235112
commit b177e7e16d
15 changed files with 665 additions and 2 deletions

View File

@ -6,6 +6,7 @@ The game includes the mods from the default [minetest_game](https://github.com/m
The following mods are also included:
* [awards][] ([LGPL](mods/awards/LICENSE.txt))
* buildings/
* barn ([mobf_core modpack][mobf]) ([CC-BY-SA](doc/modpacks/mobf_core/License.txt))
* building_blocks ([homedecor_modpack][homedecor]) ([LGPL/WTFPL/CC-BY-SA](doc/modpacks/homedecor/LICENSE))
* chains ([homedecor_modpack][homedecor])
* computer ([homedecor_modpack][homedecor])
@ -44,8 +45,8 @@ The following mods are also included:
* [mesecons (modpack)][mesecons] ([LGPL/CC-BY-SA](mods/mesecons/COPYING.txt))
* mob_engines/
* [creatures (Creatures MOB-Engine)][cme] ([zlib/CC-BY-SA](doc/modpacks/cme/README.txt))
* [mobf (mobf_core modpack)][mobf] ([CC-BY-SA](doc/modpacks/mobf_core/License.txt))
* [mobf_settings (mobf_core modpack)][mobf]
* mobf ([mobf_core modpack][mobf]) ([CC-BY-SA](doc/modpacks/mobf_core/License.txt))
* mobf_settings ([mobf_core modpack][mobf]) ([CC-BY-SA](doc/modpacks/mobf_core/License.txt))
* [pipeworks][] ([WTFPL](mods/pipeworks/LICENSE))
* plantlife/
* player/

View File

@ -0,0 +1,3 @@
default
mobf
intllib?

View File

@ -0,0 +1,389 @@
-------------------------------------------------------------------------------
-- Mob Framework Mod by Sapier
--
-- You may copy, use, modify or do nearly anything except removing this
-- copyright notice.
-- And of course you are NOT allow to pretend you have written it.
--
--! @file init.lua
--! @brief barn implementation
--! @copyright Sapier
--! @author Sapier
--! @date 2013-01-27
--
-- Contact sapier a t gmx net
-------------------------------------------------------------------------------
-- Boilerplate to support localized strings if intllib mod is installed.
local S
if (minetest.get_modpath("intllib")) then
dofile(minetest.get_modpath("intllib").."/intllib.lua")
S = intllib.Getter(minetest.get_current_modname())
else
S = function ( s ) return s end
end
minetest.log("action","MOD: barn mod loading ...")
local version = "0.0.13"
local modpath = minetest.get_modpath("barn")
barn_breedpairs_big = {
{ "animal_sheep:sheep","animal_sheep:sheep","animal_sheep:lamb","animal_sheep:lamb"},
{ "animal_cow:cow","animal_cow:steer","animal_cow:baby_calf_m","animal_cow:baby_calf_f"},
}
barn_breedpairs_small = {
{ "animal_chicken:chicken","animal_chicken:rooster","animal_chicken:chick_m","animal_chicken:chick_f"},
}
--include debug trace functions
dofile (modpath .. "/model.lua")
minetest.register_craftitem("barn:barn_empty", {
description = S("Barn to breed animals"),
image = minetest.inventorycube("barn_3d_empty_top.png","barn_3d_empty_side.png","barn_3d_empty_side.png"),
on_place = function(item, placer, pointed_thing)
if pointed_thing.type == "node" then
local pos = pointed_thing.above
local newobject = minetest.add_entity(pos,"barn:barn_empty_ent")
item:take_item()
return item
end
end
})
minetest.register_craftitem("barn:barn_small_empty", {
description = S("Barn to breed small animals"),
image = "barn_small.png",
on_place = function(item, placer, pointed_thing)
if pointed_thing.type == "node" then
local pos = pointed_thing.above
local newobject = minetest.add_entity(pos,"barn:barn_small_empty_ent")
item:take_item()
return item
end
end
})
minetest.register_craft({
output = "barn:barn_empty 1",
recipe = {
{'default:stick', 'default:stick','default:stick'},
{'default:wood','default:wood','default:wood'},
}
})
minetest.register_craft({
output = "barn:barn_small_empty 1",
recipe = {
{'default:stick', 'default:stick'},
{'default:wood','default:wood'},
}
})
function is_food(name)
if name == "default:leaves" then
return true
end
if name == "default:junglegrass" then
return true
end
return false
end
function breed(breedpairs,self,now)
local pos = self.object:getpos()
local objectlist = minetest.get_objects_inside_radius(pos,2)
local le_animal1 = nil
local le_animal2 = nil
for index,value in pairs(objectlist) do
local luaentity = value:get_luaentity()
local mobname = nil
if luaentity ~= nil and
luaentity.data ~= nil and
luaentity.data.name ~= nil and
luaentity.data.modname ~= nil then
mobname = luaentity.data.modname .. ":" .. luaentity.data.name
end
if mobname ~= nil and
mobname == breedpairs[1] and
luaentity ~= le_animal1 and
le_animal2 == nil then
le_animal2 = luaentity
end
if mobname ~= nil and
mobname == breedpairs[2] and
le_animal2 ~= luaentity then
le_animal1 = luaentity
end
if le_animal1 ~= nil and
le_animal2 ~= nil then
break
end
end
if math.random() < (0.0001 * (now - (self.last_breed_time + 30))) and
self.last_breed_time > 0 and
le_animal1 ~= nil and
le_animal2 ~= nil then
local pos1 = le_animal1.object:getpos()
local pos2 = le_animal2.object:getpos()
local pos = self.object:getpos()
local pos_to_breed = {
x = pos1.x + (pos2.x - pos1.x) /2,
y = pos1.y,
z = pos1.z + (pos2.z - pos1.z) /2,
}
--TODO check position by now this is done by spawn algorithm only
local result = breedpairs[math.random(3,4)]
local breeded = minetest.add_entity(pos_to_breed ,result)
local breeded_lua = breeded:get_luaentity()
if breeded_lua.dynamic_data.spawning == nil then
breeded_lua.dynamic_data.spawning = {}
end
breeded_lua.dynamic_data.spawning.player_spawned = true
if le_animal1.dynamic_data.spawning.spawner ~= nil then
breeded_lua.dynamic_data.spawning.spawner = le_animal1.dynamic_data.spawning.spawner
elseif le_animal2.dynamic_data.spawning.spawner ~= nil then
breeded_lua.dynamic_data.spawning.spawner = le_animal2.dynamic_data.spawning.spawner
end
return true
end
return false
end
--Entity
minetest.register_entity(":barn:barn_ent",
{
physical = true,
collisionbox = {-0.5,-0.5,-0.5, 0.5,0.5,0.5},
visual = "wielditem",
textures = { "barn:box_filled"},
visual_size = { x=0.666,y=0.666,z=0.666},
on_step = function(self,dtime)
local now = os.time(os.date('*t'))
if now ~= self.last_check_time then
local select = math.random(1,#barn_breedpairs_big)
local breedpairs = barn_breedpairs_big[select]
--print("Selected " .. select .. " --> " ..dump(breedpairs))
if breed(breedpairs,self,now) then
local pos = self.object:getpos()
--remove barn and add empty one
self.object:remove()
local barn_empty = minetest.add_entity(pos,"barn:barn_empty_ent")
local barn_empty_lua = barn_empty:get_luaentity()
barn_empty_lua.last_breed_time = now
end
self.last_check_time = now
end
end,
on_activate = function(self,staticdata)
if staticdata == nil then
self.last_breed_time = os.time(os.date('*t'))
else
self.last_breed_time = tonumber(staticdata)
end
self.last_check_time = os.time(os.date('*t'))
end,
get_staticdata = function(self)
return self.last_breed_time
end,
on_punch = function(self,player)
player:get_inventory():add_item("main", "barn:barn_empty 1")
self.object:remove()
end,
last_breed_time = -1,
last_check_time = -1,
})
minetest.register_entity(":barn:barn_empty_ent",
{
physical = true,
collisionbox = {-0.5,-0.5,-0.5, 0.5,0.5,0.5},
visual = "wielditem",
textures = { "barn:box_empty"},
visual_size = { x=0.666,y=0.666,z=0.666},
on_punch = function(self,player)
if player == nil then
return
end
if not player:is_player() then
return
end
--if player is wearing food replace by full barn
local tool = player:get_wielded_item()
if is_food(tool:get_name()) then
local time_of_last_breed = self.last_breed_time
local pos = self.object:getpos()
self.object:remove()
local barn = minetest.add_entity(pos,"barn:barn_ent")
local barn_lua = barn:get_luaentity()
barn_lua.last_breed_time = time_of_last_breed
player:get_inventory():remove_item("main",tool:get_name().." 1")
--else add to players inventory
else
player:get_inventory():add_item("main", "barn:barn_empty 1")
self.object:remove()
end
end,
on_activate = function(self, staticdata)
self.last_breed_time = os.time(os.date('*t'))
self.last_check_time = self.last_breed_time
end,
})
minetest.register_entity(":barn:barn_small_ent",
{
physical = true,
collisionbox = {-0.5,-0.5,-0.5, 0.5,-0.2,0.5},
visual = "wielditem",
textures = { "barn:box_small_filled"},
visual_size = { x=0.666,y=0.666,z=0.666},
on_step = function(self,dtime)
local now = os.time(os.date('*t'))
if now ~= self.last_check_time then
local select = math.random(1,#barn_breedpairs_small)
local breedpairs = barn_breedpairs_small[select]
--print("Selected " .. select .. " --> " ..dump(breedpairs))
if breed(breedpairs,self,now) then
local pos = self.object:getpos()
--remove barn and add empty one
self.object:remove()
local barn_empty = minetest.add_entity(pos,"barn:barn_small_empty_ent")
local barn_empty_lua = barn_empty:get_luaentity()
barn_empty_lua.last_breed_time = now
end
self.last_check_time = now
end
end,
on_activate = function(self,staticdata)
if staticdata == nil then
self.last_breed_time = os.time(os.date('*t'))
else
self.last_breed_time = tonumber(staticdata)
end
self.last_check_time = os.time(os.date('*t'))
end,
get_staticdata = function(self)
return self.last_breed_time
end,
on_punch = function(self,player)
player:get_inventory():add_item("main", "barn:barn_small_empty 1")
self.object:remove()
end,
last_breed_time = -1,
last_check_time = -1,
})
minetest.register_entity(":barn:barn_small_empty_ent",
{
physical = true,
collisionbox = {-0.5,-0.5,-0.5, 0.5,-0.2,0.5},
visual = "wielditem",
textures = { "barn:box_small_empty"},
visual_size = { x=0.666,y=0.666,z=0.666},
on_punch = function(self,player)
--if player is wearing food replace by full barn
local tool = player:get_wielded_item()
if is_food(tool:get_name()) then
local time_of_last_breed = self.last_breed_time
local pos = self.object:getpos()
self.object:remove()
local barn = minetest.add_entity(pos,"barn:barn_small_ent")
local barn_lua = barn:get_luaentity()
barn_lua.last_breed_time = time_of_last_breed
player:get_inventory():remove_item("main",tool:get_name().." 1")
--else add to players inventory
else
player:get_inventory():add_item("main", "barn:barn_small_empty 1")
self.object:remove()
end
end,
on_activate = function(self, staticdata)
self.last_breed_time = os.time(os.date('*t'))
self.last_check_time = self.last_breed_time
end,
})
minetest.log("action","MOD: barn mod version " .. version .. " loaded")

View File

@ -0,0 +1,4 @@
# Translation by Xanthin
Barn to breed animals = Raufe um Tiere zu zuechten
Barn to breed small animals = Raufe um kleine Tiere zu zuechten

View File

@ -0,0 +1,6 @@
# Spanish translation for Animals Modpack.
# Traducción al español de Animals Modpack.
# Author/Autor: Diego Martínez <kaeza>
Barn to breed animals = Granero para criar animales
Barn to breed small animals = Granero para criar animales pequenos

View File

@ -0,0 +1,4 @@
# Template
Barn to breed animals =
Barn to breed small animals =

View File

@ -0,0 +1,256 @@
function x(val)
return ((val -80) / 160)
end
function z(val)
return ((val -80) / 160)
end
function y(val)
return ((val + 80) / 160)
end
local textures_small_empty = {
"barn_3d_bottom.png",
}
local textures_small_filled = {
"barn_3d_small_top.png",
"barn_3d_bottom.png",
"barn_3d_bottom.png",
}
local textures_empty = {
"barn_3d_bottom.png",
"barn_3d_empty_top.png",
"barn_3d_empty_side.png",
"barn_3d_empty_side.png",
"barn_3d_empty_side.png",
"barn_3d_empty_side.png",
}
local textures_filled = {
"barn_3d_filled_top.png",
"barn_3d_bottom.png",
"barn_3d_filled_side.png",
"barn_3d_filled_side.png",
"barn_3d_filled_side.png",
"barn_3d_filled_side.png",
}
local box_barn_small_empty = {
--floor
{ x(0) , y(-150), z(160),
x(160), y(-160), z(0) },
{ x(0) , y(-120),z(160),
x(160),y(-150),z(150) },
{ x(0) , y(-120),z(10),
x(160),y(-150),z(0) },
{ x(0) , y(-120),z(160),
x(10),y(-150),z(0) },
{ x(150) , y(-120),z(160),
x(160),y(-150),z(0) }
}
local box_barn_small_filled = {
--floor
{ x(0) , y(-150), z(160),
x(160), y(-160), z(0) },
{ x(0) , y(-120),z(160),
x(160),y(-150),z(150) },
{ x(0) , y(-120),z(10),
x(160),y(-150),z(0) },
{ x(0) , y(-120),z(160),
x(10),y(-150),z(0) },
{ x(150) , y(-120),z(160),
x(160),y(-150),z(0) },
{ x(10), y(-125), z(150),
x(150),y(-150),z(10) }
}
local box_barn_empty = {
--floor
{ x(0) , y(-150), z(160),
x(160), y(-160), z(0) },
--x edge front
{ x(0) , y(0), z(160),
x(20), y(-150), z(140) },
{ x(47), y(0), z(160),
x(66), y(-150), z(140) },
{ x(94), y(0), z(160),
x(113), y(-150), z(140) },
{ x(140), y(0), z(160),
x(160), y(-150), z(140) },
--x edge back
{ x(0), y(0), z(20),
x(20), y(-150), z(0) },
{ x(47), y(0), z(20),
x(66), y(-150), z(0) },
{ x(94), y(0), z(20),
x(113), y(-150), z(0) },
{ x(140), y(0), z(20),
x(160), y(-150), z(0) },
-- z edge right
{ x(140), y(0), z(66),
x(160), y(-160), z(47) },
{ x(140), y(0), z(113),
x(160), y(-150), z(94) },
-- z edge left
{ x(0), y(0), z(66),
x(20), y(-150), z(47) },
{ x(0), y(0), z(113),
x(20), y(-150), z(94) },
--metal plates
{ x(10), y(-50), z(150),
x(150), y(-70), z(140),},
{ x(10), y(-130), z(150),
x(150), y(-150), z(140)},
{ x(10), y(-50), z(20),
x(150), y(-70), z(10),},
{ x(10), y(-130), z(20),
x(150), y(-150), z(10)},
{ x(10), y(-50), z(150),
x(20), y(-70), z(10),},
{ x(10), y(-130), z(150),
x(20), y(-150), z(10),},
{ x(140), y(-50), z(150),
x(150), y(-70), z(10),},
{ x(140), y(-130), z(150),
x(150), y(-150), z(10),},
}
local box_barn_filled = {
--floor
{ x(0) , y(-150), z(160),
x(160), y(-160), z(0) },
--x edge front
{ x(0) , y(0), z(160),
x(20), y(-150), z(140) },
{ x(47), y(0), z(160),
x(66), y(-150), z(140) },
{ x(94), y(0), z(160),
x(113), y(-150), z(140) },
{ x(140), y(0), z(160),
x(160), y(-150), z(140) },
--x edge back
{ x(0), y(0), z(20),
x(20), y(-150), z(0) },
{ x(47), y(0), z(20),
x(66), y(-150), z(0) },
{ x(94), y(0), z(20),
x(113), y(-150), z(0) },
{ x(140), y(0), z(20),
x(160), y(-150), z(0) },
-- z edge right
{ x(140), y(0), z(66),
x(160), y(-160), z(47) },
{ x(140), y(0), z(113),
x(160), y(-150), z(94) },
-- z edge left
{ x(0), y(0), z(66),
x(20), y(-150), z(47) },
{ x(0), y(0), z(113),
x(20), y(-150), z(94) },
--metal plates
{ x(10), y(-50), z(150),
x(150), y(-70), z(140)},
{ x(10), y(-130), z(150),
x(150), y(-150), z(140)},
{ x(10), y(-50), z(20),
x(150), y(-70), z(10)},
{ x(10), y(-130), z(20),
x(150), y(-150), z(10)},
{ x(10), y(-50), z(150),
x(20), y(-70), z(10)},
{ x(10), y(-130), z(150),
x(20), y(-150), z(10)},
{ x(140), y(-50), z(150),
x(150), y(-70), z(10)},
{ x(140), y(-130), z(150),
x(150), y(-150), z(10)},
--grass
{ x(20), y(-30), z(140),
x(140), y(-130), z(20)}
}
minetest.register_node("barn:box_empty", {
tiles = textures_empty,
drawtype = "nodebox",
node_box = {
type = "fixed",
fixed = box_barn_empty
},
})
minetest.register_node("barn:box_filled", {
tiles = textures_filled,
drawtype = "nodebox",
node_box = {
type = "fixed",
fixed = box_barn_filled
},
})
minetest.register_node("barn:box_small_empty", {
tiles = textures_small_empty,
drawtype = "nodebox",
node_box = {
type = "fixed",
fixed = box_barn_small_empty
},
})
minetest.register_node("barn:box_small_filled", {
tiles = textures_small_filled,
drawtype = "nodebox",
node_box = {
type = "fixed",
fixed = box_barn_small_filled
},
})

Binary file not shown.

After

Width:  |  Height:  |  Size: 46 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 44 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 36 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 53 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 40 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 44 KiB