update animals and hydro

master
cornernote 2012-08-09 17:49:47 +09:30
parent 19bfd364f4
commit d89efba546
37 changed files with 620 additions and 160 deletions

View File

@ -1,4 +1,16 @@
local version = "0.0.4"
local version = "0.0.5"
local cow_groups = {
not_in_creative_inventory=1
}
local selectionbox_cow = {-1.5, -1.5, -0.75, 1.5, 0.6, 0.75}
local modpath = minetest.get_modpath("animal_cow")
--include debug trace functions
dofile (modpath .. "/model.lua")
cow_prototype = {
name="cow",
@ -10,13 +22,15 @@ cow_prototype = {
kill_result="animalmaterials:meat_raw 5",
armor_groups= {
fleshy=2,
}
},
groups = cow_groups
},
movement = {
default_gen=movement_gen,
min_accel=0.1,
max_accel=0.3,
max_speed=1.2,
min_speed=0.2,
pattern="stop_and_go_meadow"
},
harvest = {
@ -33,9 +47,10 @@ cow_prototype = {
random_drop = nil,
auto_transform = nil,
graphics = {
sprite_scale={x=4,y=4},
sprite_div = {x=6,y=1},
visible_height = 2,
visual = "wielditem",
textures = {"animal_cow:box_cow"},
collisionbox = selectionbox_cow,
visual_size= {x=2,y=2,z=2},
},
combat = nil,

View File

@ -0,0 +1,64 @@
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_cow = {
"animals_cow_bottom.png",
"animals_cow_top.png",
"animals_cow_front.png",
"animals_cow_back.png",
"animals_cow_left.png",
"animals_cow_right.png",
}
local nodebox_cow ={
--snut
{ x(140), y(-70), z(90), x(160), y(-90), z(70) },
--head
{ x(120), y(-60), z(90), x(140), y(-90), z(70) },
--neck
{ x(110), y(-50), z(110), x(120), y(-90), z(50) },
--body
{ x(10), y(-50), z(120), x(110), y(-110),z(40) },
--tail
{ x(0), y(-50), z(85), x(10), y(-120),z(75) },
--legs
--vl
{ x(90), y(-110), z(110), x(100), y(-160), z(100) },
{ x(80), y(-110), z(110), x(90), y(-130), z(100) },
--vr
{ x(90), y(-110), z(60), x(100), y(-160), z(50) },
{ x(80), y(-110), z(60), x(90), y(-130), z(50) },
--hl
{ x(10), y(-110), z(110), x(20), y(-160), z(100) },
{ x(10), y(-110), z(110), x(30), y(-130), z(100) },
--hr
{ x(10), y(-110), z(60), x(20), y(-160), z(50) },
{ x(10), y(-110), z(60), x(30), y(-130), z(50) },
--udder
{ x(30), y(-110), z(90), x(50), y(-130), z(70) }
}
minetest.register_node("animal_cow:box_cow", {
tiles = textures_cow,
drawtype = "nodebox",
node_box = {
type = "fixed",
fixed = nodebox_cow
},
groups = cow_groups
})

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

View File

@ -1,4 +1,18 @@
local version = "0.0.5"
local version = "0.0.8"
local sheep_groups = {
sheerable=1,
wool=1,
not_in_creative_inventory=1
}
local selectionbox_sheep = {-0.65, -0.8, -0.65, 0.65, 0.45, 0.65}
local selectionbox_lamb = {-0.65*0.6, -0.8*0.6, -0.65*0.6, 0.65*0.6, 0.45*0.6, 0.65*0.65}
local modpath = minetest.get_modpath("animal_sheep")
--include debug trace functions
dofile (modpath .. "/model.lua")
sheep_prototype = {
name="sheep",
@ -11,16 +25,14 @@ sheep_prototype = {
armor_groups= {
fleshy=3,
},
groups = {
sheerable=1,
wool=1,
}
groups = sheep_groups
},
movement = {
default_gen=movement_gen,
min_accel=0.2,
max_accel=0.4,
max_speed=1.5,
min_speed=0.2,
pattern="stop_and_go_meadow"
},
harvest = {
@ -38,9 +50,10 @@ sheep_prototype = {
random_drop = nil,
auto_transform = nil,
graphics = {
sprite_scale={x=4,y=4},
sprite_div = {x=6,y=1},
visible_height = 1.5,
visual = "wielditem",
textures = {"animal_sheep:box_wool"},
collisionbox = selectionbox_sheep,
visual_size= {x=1,y=1,z=1},
},
combat = nil,
@ -68,7 +81,7 @@ sheep_prototype = {
},
}
lamp_prototype = {
lamb_prototype = {
name="lamb",
modname="animal_sheep",
@ -81,6 +94,7 @@ lamp_prototype = {
}
},
movement = {
default_gen=movement_gen,
min_accel=0.1,
max_accel=0.2,
max_speed=1,
@ -97,8 +111,10 @@ lamp_prototype = {
delay=1800
},
graphics = {
sprite_scale={x=4,y=4},
sprite_div = {x=6,y=1},
visual = "wielditem",
textures = {"animal_sheep:box_wool"},
collisionbox = selectionbox_lamb,
visual_size= {x=0.6,y=1,z=0.6},
visible_height = 1,
},
combat = nil,
@ -133,10 +149,12 @@ sheep_naked_prototype = {
fleshy=3,
},
},
movement = {
movement = {
default_gen=movement_gen,
min_accel=0.2,
max_accel=0.4,
max_speed=1.5,
min_speed=0.2,
pattern="stop_and_go"
},
harvest = nil,
@ -150,10 +168,12 @@ sheep_naked_prototype = {
delay=300
},
graphics = {
sprite_scale={x=4,y=4},
sprite_div = {x=6,y=1},
visible_height = 1.5,
},
visual = "wielditem",
textures = {"animal_sheep:box_naked"},
collisionbox = selectionbox_sheep,
visual_size= {x=1,y=1,z=1},
visible_height = 1,
},
combat = nil,
spawning = {
@ -189,6 +209,6 @@ print ("Adding animal "..sheep_prototype.name)
animals_add_animal(sheep_prototype)
print ("Adding animal "..sheep_naked_prototype.name)
animals_add_animal(sheep_naked_prototype)
print ("Adding animal "..lamp_prototype.name)
animals_add_animal(lamp_prototype)
print ("Adding animal "..lamb_prototype.name)
animals_add_animal(lamb_prototype)
print ("animal_sheep mod version " .. version .. " loaded")

View File

@ -0,0 +1,47 @@
local textures_wool = {"animals_sheep_wool.png",
"animals_sheep_wool.png",
"animals_sheep_front.png",
"animals_sheep_wool.png",
"animals_sheep_wool.png",
"animals_sheep_wool.png"}
local textures_naked = {"animals_sheep_no_wool.png",
"animals_sheep_no_wool.png",
"animals_sheep_no_wool_front.png",
"animals_sheep_no_wool.png",
"animals_sheep_no_wool.png",
"animals_sheep_no_wool.png"}
local nodebox_sheep = {
-- legs
{-0.25, -0.25-0.25, -0.2, -0.15, 0.125-0.25, -0.1},
{0.15, 0.125-0.25, -0.1, 0.25, -0.25-0.25, -0.2},
{-0.15, 0.125-0.25, 0.1, -0.25, -0.25-0.25, 0.2},
{0.25, -0.25-0.25, 0.2, 0.15, 0.125-0.25, 0.1},
-- body
{-0.25, 0.125-0.25, -0.2, 0.25, 0.35-0.25, 0.2},
-- head
{0.25, 0.275-0.25, -0.1, 0.5, 0.5-0.25, 0.1},
}
minetest.register_node("animal_sheep:box_wool", {
tiles = textures_wool,
drawtype = "nodebox",
node_box = {
type = "fixed",
fixed = nodebox_sheep
},
groups = sheep_groups
})
minetest.register_node("animal_sheep:box_naked", {
tiles = textures_naked,
drawtype = "nodebox",
node_box = {
type = "fixed",
fixed = nodebox_sheep
},
groups = sheep_groups
})

Binary file not shown.

After

Width:  |  Height:  |  Size: 976 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 839 B

View File

@ -1,4 +1,4 @@
local version = "0.0.7"
local version = "0.0.8"
--+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
--+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
-- Node definitions
@ -13,22 +13,22 @@ local version = "0.0.7"
-------------------------------------------------------------------------------
minetest.register_node("animalmaterials:wool_white", {
description = "Wool (white)",
tile_images = {"animalmaterials_wool_white.png"},
tiles = {"animalmaterials_wool_white.png"},
groups = { snappy=3,wool=1 }
})
minetest.register_node("animalmaterials:wool_grey", {
description = "Wool (grey)",
tile_images = {"animalmaterials_wool_grey.png"},
tiles = {"animalmaterials_wool_grey.png"},
groups = { snappy=3, wool=1 }
})
minetest.register_node("animalmaterials:wool_brown", {
description = "Wool (grey)",
tile_images = {"animalmaterials_wool_grey.png"},
tiles = {"animalmaterials_wool_grey.png"},
groups = { snappy=3, wool=1 }
})
minetest.register_node("animalmaterials:wool_black", {
description = "Wool (grey)",
tile_images = {"animalmaterials_wool_black.png"},
tiles = {"animalmaterials_wool_black.png"},
groups = { snappy=3, wool=1 }
})

View File

@ -107,6 +107,24 @@ wood wood wood
Changelog:
-------------------------------------------------------------------------------
Changes 1.2.93:
-added 3d barn
-fixed bug animals have wrong orientation
-fixed bug sheep get stuc in corner
-fixed cow model
Changes 1.2.92:
-added support for 3d animals
-fix bug in probabilistic movement gen when handling min speed
-fixed movement of stop_and_go animals
-made Sheep 3D
-made Cow 3D
Changes 1.2.91:
-fixed bugs in animals sheep
-updated animalmaterials to new syntax
Changes 1.2.90:
-added support for surface differentiation in good/ok/bad
-added support for different movement generators

View File

@ -38,7 +38,7 @@ dofile (animals_modpath .. "/debug.lua")
--include spawning support
dofile (animals_modpath .. "/spawning.lua")
local version = "1.2.90"
local version = "1.2.93"
LOGLEVEL_INFO = "verbose"
LOGLEVEL_NOTICE = "info"

View File

@ -66,20 +66,28 @@ function animals_add_animal(animal)
if animal.random_drop ~= nil then
random_drop.register(animal)
end
--register animal entity
minetest.register_entity(":".. animal.modname .. ":"..animal.name,
{
physical = true,
collisionbox = {-0.5,
--2D legacy support
if (animal.graphics.visual == nil) then
animal.graphics.collisionbox = {-0.5,
-0.5 * animal.graphics.visible_height,
-0.5,
0.5,
0.5 * animal.graphics.visible_height,
0.5},
visual = "sprite",
visual_size = animal.graphics.sprite_scale,
textures = {animal.modname.."_"..animal.name..".png^[makealpha:128,0,0^[makealpha:128,128,0"},
0.5}
animal.graphics.visual = "sprite"
animal.graphics.textures = {animal.modname.."_"..animal.name..".png^[makealpha:128,0,0^[makealpha:128,128,0"}
animal.graphics.visual_size = animal.graphics.sprite_scale
end
--register animal entity
minetest.register_entity(":".. animal.modname .. ":"..animal.name,
{
physical = true,
collisionbox = animal.graphics.collisionbox,
visual = animal.graphics.visual,
visual_size = animal.graphics.visual_size,
textures = animal.graphics.textures,
spritediv = animal.graphics.sprite_div,
initial_sprite_basepos = {x=0, y=0},
makes_footstep_sound = true,
@ -120,7 +128,7 @@ function animals_add_animal(animal)
sound.play_random(self,now)
--visual change hook
update_orientation(self,now)
update_orientation(self,now)
end,
--player <-> animal interaction
@ -202,22 +210,43 @@ function animals_add_animal(animal)
end
--initialize height level
if self.data.graphics.visible_height > 1 then
local pos_to_check = {x=pos.x,y=pos.y-0.51,z=pos.z}
local node_pos = minetest.env:get_node(pos)
local node_pos_check = minetest.env:get_node(pos_to_check)
if node_pos ~= nil and
node_pos_check ~= nil then
--print("ANIMALS: fixing spawn position required? " .. node_pos.name .. " " .. node_pos_check.name)
if node_pos.name ~= node_pos_check.name then
pos.y = pos.y + ((self.data.graphics.visible_height -1)/2)
--print("ANIMALS: fixing spawn position moving to " ..printpos(pos))
self.object:moveto(pos)
--legacy 2D mode
if self.data.graphics.visual == "sprite" or
self.data.graphics.visual == nil then
if self.data.graphics.visible_height > 1 then
local pos_to_check = {x=pos.x,y=pos.y-0.51,z=pos.z}
local node_pos = minetest.env:get_node(pos)
local node_pos_check = minetest.env:get_node(pos_to_check)
if node_pos ~= nil and
node_pos_check ~= nil then
--print("ANIMALS: fixing spawn position required? " .. node_pos.name .. " " .. node_pos_check.name)
if node_pos.name ~= node_pos_check.name then
pos.y = pos.y + ((self.data.graphics.visible_height -1)/2)
--print("ANIMALS: fixing spawn position moving to " ..printpos(pos))
self.object:moveto(pos)
end
end
end
else
if self.data.graphics.collisionbox[1] < -0.5 then
local pos_to_check = {x=pos.x,y=pos.y+self.data.graphics.collisionbox[1],z=pos.z}
local node_pos = minetest.env:get_node(pos)
local node_pos_check = minetest.env:get_node(pos_to_check)
if node_pos ~= nil and
node_pos_check ~= nil then
dbg_animals.generic_lvl2("ANIMALS: fixing spawn position required? " .. node_pos.name .. " " .. node_pos_check.name)
if node_pos.name ~= node_pos_check.name then
pos.y = pos.y + ((0.5 + self.data.graphics.collisionbox[1]) * -1)
dbg_animals.generic_lvl2("ANIMALS: fixing spawn position moving to " ..printpos(pos))
self.object:moveto(pos)
end
end
end
end
--initialize sprites
@ -247,12 +276,26 @@ function animals_add_animal(animal)
getbasepos = function(entity)
local pos = entity.object:getpos()
dbg_animals.generic_lvl2("ANIMALS: Center Position: " .. printpos(pos))
-- if visual height is more than one block the center of base block is
-- below the entities center
if (entity.data.graphics.visible_height > 1) then
pos.y = pos.y - (entity.data.graphics.visible_height/2) + 0.5
-- legacy 2D mode
if (entity.data.graphics.visual == "sprite" ) or
(entity.data.graphics.visual == nil )then
if (entity.data.graphics.visible_height > 1) then
pos.y = pos.y - (entity.data.graphics.visible_height/2) + 0.5
end
else
if (entity.data.graphics.collisionbox[1] < -0.5) then
pos.y = pos.y + (entity.data.graphics.collisionbox[1] + 0.5)
dbg_animals.generic_lvl2("ANIMALS: collision box lower end: " .. entity.data.graphics.collisionbox[1])
end
end
dbg_animals.generic_lvl2("ANIMALS: Base Position: " .. printpos(pos))
return pos
end
@ -267,7 +310,7 @@ function animals_add_animal(animal)
--check if a movement pattern was specified
if animals_movement_patterns[animal.movement.pattern] == nil then
print("ANIMALS Warning: no movement pattern specified!")
minetest.log(LOGLEVEL_WARNING,"ANIMALS Warning: no movement pattern specified!")
end
--register spawn callback to world
@ -277,7 +320,7 @@ function animals_add_animal(animal)
secondary_name = animal.harvest.transforms_to
end
print("Pattern:" , animal.movement.pattern)
dbg_animals.generic_lvl3("Pattern:" , animal.movement.pattern)
local dummy6 = animals_movement_patterns[animal.movement.pattern].environment
animals_spawn_algorithms[animal.spawning.algorithm](animal.modname..":"..animal.name,

View File

@ -76,18 +76,18 @@ function direction_control.changeaccel(pos,prediction_time,entity,current_veloci
local state = environment.pos_is_ok(pos_predicted,entity)
while state ~= "ok" do
dbg_animals.movement_lvl1("ANIMALS: predicted pos " .. printpos(pos_predicted) .. " isn't ok " .. maxtries .. " tries left, state: " .. state)
dbg_animals.pmovement_lvl1("ANIMALS: predicted pos " .. printpos(pos_predicted) .. " isn't ok " .. maxtries .. " tries left, state: " .. state)
local done = false
--don't loop forever get to save mode and try next time
if maxtries <= 0 then
dbg_animals.movement_lvl1("ANIMALS: Aborting acceleration finding for this cycle due to max retries")
dbg_animals.pmovement_lvl1("ANIMALS: Aborting acceleration finding for this cycle due to max retries")
if state == "collision_jumpable" then
dbg_animals.movement_lvl1("Returning "..printpos(new_accel).." as new accel as animal may jump")
return new_accel
end
dbg_animals.movement_lvl1("ANIMALS: Didn't find a suitable acceleration: " .. entity.data.name .. printpos(pos))
dbg_animals.pmovement_lvl1("ANIMALS: Didn't find a suitable acceleration: " .. entity.data.name .. printpos(pos))
--don't slow down animal
return { x=current_velocity.x/-2,
y=nil,
@ -213,8 +213,11 @@ function direction_control.precheck_movement(entity,movement_state,pos_predicted
local invalid_pos_handled = false
-- animal would walk onto water
if movement_state.changed == false and pos_predicted_state == "above_water" then
dbg_animals.movement_lvl1("animal is going to walk on water")
if movement_state.changed == false and
( pos_predicted_state == "above_water" or
pos_predicted_state == "drop")
then
dbg_animals.pmovement_lvl1("animal is going to walk on water or drop")
local new_pos = movement_generic.get_suitable_pos_same_level(movement_state.basepos,1,entity)
if new_pos ~= nil then
@ -223,7 +226,7 @@ function direction_control.precheck_movement(entity,movement_state,pos_predicted
movement_state.changed = true
else
minetest.log(LOGLEVEL_ERROR,"ANIMALS: BUG!!! didn't find a way to stop animal at"..printpos(movement_state.basepos)..
"from running into water")
"from running into water or dropping")
--TODO delete animal??
end
end
@ -233,9 +236,9 @@ function direction_control.precheck_movement(entity,movement_state,pos_predicted
if environment.pos_is_ok({x=pos_predicted.x,y=pos_predicted.y+1,z=pos_predicted.z},entity) == "ok" then
if math.random() < entity.animals_mpattern.jump_up then
local node_at_predicted_pos = minetest.env:get_node(pos_predicted)
dbg_animals.movement_lvl2("ANIMALS: velocity is:" .. printpos(movement_state.current_velocity) .. " position is: "..printpos(pos) )
dbg_animals.movement_lvl2("ANIMALS: estimated position was: "..printpos(pos_predicted))
dbg_animals.movement_lvl2("ANIMALS: predicted node state is: " .. environment.pos_is_ok(pos_predicted,entity))
dbg_animals.pmovement_lvl2("ANIMALS: velocity is:" .. printpos(movement_state.current_velocity) .. " position is: "..printpos(pos) )
dbg_animals.pmovement_lvl2("ANIMALS: estimated position was: "..printpos(pos_predicted))
dbg_animals.pmovement_lvl2("ANIMALS: predicted node state is: " .. environment.pos_is_ok(pos_predicted,entity))
--if node_at_predicted_pos ~= nil then
--dbg_animals.movement_lvl1("ANIMALS: jumping onto: " .. node_at_predicted_pos.name)
--end
@ -245,8 +248,8 @@ function direction_control.precheck_movement(entity,movement_state,pos_predicted
--todo check if y pos is ok?!
local jumppos = {x=pos_predicted.x,y=movement_state.centerpos.y+1,z=pos_predicted.z}
dbg_animals.movement_lvl2("ANIMALS: animal " ..entity.data.name .. " is jumping, moving to:" .. printpos(jumppos))
dbg_animals.movement_lvl2("ANIMALS: target pos node state is: " .. environment.pos_is_ok(jumppos,entity))
dbg_animals.pmovement_lvl2("ANIMALS: animal " ..entity.data.name .. " is jumping, moving to:" .. printpos(jumppos))
dbg_animals.pmovement_lvl2("ANIMALS: target pos node state is: " .. environment.pos_is_ok(jumppos,entity))
entity.object:moveto(jumppos)
--TODO set movement state positions
@ -259,7 +262,7 @@ function direction_control.precheck_movement(entity,movement_state,pos_predicted
--redirect animal to block thats not above its current level
--or jump if possible
if movement_state.changed == false and pos_predicted_state == "collision" then
dbg_animals.movement_lvl1("ANIMALS: animal is about to collide")
dbg_animals.pmovement_lvl1("ANIMALS: animal is about to collide")
local new_pos = movement_generic.get_suitable_pos_same_level(movement_state.basepos,1,entity)
@ -292,7 +295,7 @@ function direction_control.precheck_movement(entity,movement_state,pos_predicted
if jumppos ~= nil then
dbg_animals.movement_lvl2("ANIMALS: animal " ..entity.data.name .. " seems to be locked in, moving to:" .. printpos(jumppos))
dbg_animals.pmovement_lvl2("ANIMALS: animal " ..entity.data.name .. " seems to be locked in, moving to:" .. printpos(jumppos))
entity.object:moveto(jumppos)
movement_state.accel_to_set = { x=0,y=nil,z=0 }
@ -305,7 +308,7 @@ function direction_control.precheck_movement(entity,movement_state,pos_predicted
--generic try to solve situation eg wrong surface
if movement_state.changed == false and
invalid_pos_handled == false then
dbg_animals.movement_lvl1("ANIMALS: generic try to resolve state " .. pos_predicted_state .. " for animal " .. entity.data.name .. " "..printpos(movement_state.basepos))
dbg_animals.pmovement_lvl1("ANIMALS: generic try to resolve state " .. pos_predicted_state .. " for animal " .. entity.data.name .. " "..printpos(movement_state.basepos))
movement_state.accel_to_set = direction_control.changeaccel(movement_state.basepos,prediction_time,
entity,movement_state.current_velocity)
if movement_state.accel_to_set ~= nil then
@ -324,7 +327,8 @@ end
-- param2: movement_state
-- retval: is a modification to accel done by random jump code?
-------------------------------------------------------------------------------
function direction_control.random_movement_handler(entity,movement_state)
function direction_control.random_movement_handler(entity,movement_state)
dbg_animals.pmovement_lvl1("ANIMALS: random movement handler called")
if movement_state.changed == false and
(math.random() < entity.animals_mpattern.random_acceleration_change or
movement_state.force_change) then
@ -336,6 +340,6 @@ function direction_control.random_movement_handler(entity,movement_state)
movement_state.accel_to_set.y = movement_state.current_acceleration.y
movement_state.changed = true
end
dbg_animals.movement_lvl1("ANIMALS: randomly changing speed from "..printpos(movement_state.current_acceleration).." to "..printpos(movement_state.accel_to_set))
dbg_animals.pmovement_lvl1("ANIMALS: randomly changing speed from "..printpos(movement_state.current_acceleration).." to "..printpos(movement_state.accel_to_set))
end
end

View File

@ -57,13 +57,13 @@ function height_level_control.precheck_movement(entity,movement_state,pos_predic
local time_completed = entity.dynamic_data.movement.ts_random_jump + level_change_time
dbg_animals.movement_lvl1("ANIMALS: ".. movement_state.now .. " " .. entity.data.name ..
dbg_animals.pmovement_lvl1("ANIMALS: ".. movement_state.now .. " " .. entity.data.name ..
" check complete level change " .. time_completed)
if entity.dynamic_data.movement.changing_levels and
time_completed < movement_state.now then
dbg_animals.movement_lvl2("ANIMALS: ".. movement_state.now .. " " .. entity.data.name ..
dbg_animals.pmovement_lvl2("ANIMALS: ".. movement_state.now .. " " .. entity.data.name ..
" level change complete reestablishing default y acceleration " .. movement_state.default_y_accel)
entity.dynamic_data.movement.changing_levels = false
@ -144,7 +144,7 @@ function height_level_control.random_jump_fly(entity,movement_state)
local target_state = environment.pos_is_ok(targetpos,entity);
dbg_animals.movement_lvl2("ANIMALS: " .. entity.data.name .." flying change y accel dir="..ydirection.." ypos="..movement_state.basepos.y..
dbg_animals.pmovement_lvl2("ANIMALS: " .. entity.data.name .." flying change y accel dir="..ydirection.." ypos="..movement_state.basepos.y..
" min="..entity.animals_mpattern.environment.min_height_above_ground..
" max="..entity.animals_mpattern.environment.max_height_above_ground..
" below="..target_state)
@ -153,7 +153,7 @@ function height_level_control.random_jump_fly(entity,movement_state)
local min_y, max_y = environment.get_absolute_min_max_pos(entity.animals_mpattern.environment,movement_state.basepos)
dbg_animals.movement_lvl2("ANIMALS: check level borders current=".. movement_state.basepos.y ..
dbg_animals.pmovement_lvl2("ANIMALS: check level borders current=".. movement_state.basepos.y ..
" min=" .. min_y ..
" max=" .. max_y)
if (movement_state.basepos.y > min_y and
@ -164,7 +164,7 @@ function height_level_control.random_jump_fly(entity,movement_state)
movement_state.accel_to_set.y = ydirection * entity.data.movement.min_accel
entity.dynamic_data.movement.ts_random_jump = movement_state.now
entity.dynamic_data.movement.changing_levels = true
dbg_animals.movement_lvl2("ANIMALS: " .. entity.data.name .. " " .. movement_state.now .. " " ..
dbg_animals.pmovement_lvl2("ANIMALS: " .. entity.data.name .. " " .. movement_state.now .. " " ..
" changing level within borders: " .. movement_state.accel_to_set.y)
movement_state.changed = true
end
@ -214,7 +214,7 @@ function height_level_control.random_jump_ground(entity,movement_state)
local current_speed = entity.object:getvelocity();
dbg_animals.movement_lvl2("ANIMALS: " .. entity.data.name .." doing random jump "..
dbg_animals.pmovement_lvl2("ANIMALS: " .. entity.data.name .." doing random jump "..
"speed: " .. entity.animals_mpattern.random_jump_initial_speed ..
": ",entity)
@ -224,7 +224,7 @@ function height_level_control.random_jump_ground(entity,movement_state)
entity.dynamic_data.movement.ts_random_jump = movement_state.now
else
dbg_animals.movement_lvl2("ANIMALS: " .. entity.data.name .. " Random jump but ground distance was:" .. ground_distance ..
dbg_animals.pmovement_lvl2("ANIMALS: " .. entity.data.name .. " Random jump but ground distance was:" .. ground_distance ..
" " ..movement_state.current_acceleration.y ..
" " ..movement_state.default_y_accel)
@ -255,7 +255,7 @@ function height_level_control.random_movement_handler(entity,movement_state)
(math.random() < entity.animals_mpattern.random_jump_chance or
math.random() < movement_state.override_height_change_chance) then
dbg_animals.movement_lvl1("ANIMALS: Random jump chance for animal " .. entity.data.name .. " "..
dbg_animals.pmovement_lvl1("ANIMALS: Random jump chance for animal " .. entity.data.name .. " "..
entity.dynamic_data.movement.ts_random_jump .. " "..
entity.animals_mpattern.random_jump_delay .. " " .. movement_state.now
)

View File

@ -77,7 +77,7 @@ function movement_gen.generator(entity)
-- --
---------------------------------------------------------------------------
---------------------------------------------------------------------------
dbg_animals.movement_lvl1("ANIMALS: position check for animal ".. entity.data.name .. " "..printpos(movement_state.basepos))
dbg_animals.pmovement_lvl1("ANIMALS: position check for animal ".. entity.data.name .. " "..printpos(movement_state.basepos))
movement_state.default_y_accel = environment.get_default_gravity(movement_state.basepos,
entity.animals_mpattern.environment.media,
entity.animals_mpattern.movement_canfly)
@ -108,7 +108,7 @@ function movement_gen.generator(entity)
-- --
---------------------------------------------------------------------------
---------------------------------------------------------------------------
dbg_animals.movement_lvl1("ANIMALS: movement hard limits check for animal ".. entity.data.name .. " "..printpos(movement_state.basepos))
dbg_animals.pmovement_lvl1("ANIMALS: movement hard limits check for animal ".. entity.data.name .. " "..printpos(movement_state.basepos))
movement_gen.fix_runaway(entity,movement_state)
movement_gen.fix_to_slow(entity,movement_state)
@ -121,7 +121,7 @@ function movement_gen.generator(entity)
-- --
---------------------------------------------------------------------------
---------------------------------------------------------------------------
dbg_animals.movement_lvl1("ANIMALS: movement check for animal ".. entity.data.name .. " "..printpos(movement_state.basepos))
dbg_animals.pmovement_lvl1("ANIMALS: movement check for animal ".. entity.data.name .. " "..printpos(movement_state.basepos))
--skip if movement already got changed
if movement_state.changed == false then
@ -153,13 +153,12 @@ function movement_gen.generator(entity)
-- --
---------------------------------------------------------------------------
---------------------------------------------------------------------------
dbg_animals.movement_lvl1("ANIMALS: randomized movement for animal ".. entity.data.name .. " "..printpos(movement_state.basepos))
dbg_animals.pmovement_lvl1("ANIMALS: randomized movement for animal ".. entity.data.name .. " "..printpos(movement_state.basepos))
--do randomized changes if not fighting
if entity.dynamic_data.combat.target == "" then
height_level_control.random_movement_handler(entity,movement_state)
direction_control.random_movement_handler(entity,movement_state)
end
height_level_control.random_movement_handler(entity,movement_state)
direction_control.random_movement_handler(entity,movement_state)
---------------------------------------------------------------------------
@ -212,10 +211,10 @@ function movement_gen.apply_movement_changes(entity,movement_state)
--if math.abs (accel_to_set.y - y_default_accel) > 0.001 then
--dbg_animals.movement_lvl1("Setting y-acceleration to: ".. accel_to_set.y .. " default:".. y_default_accel .. " name " .. entity.animals_name .. " at: " .. printpos(entity.object:getpos()))
--dbg_animals.pmovement_lvl1("Setting y-acceleration to: ".. accel_to_set.y .. " default:".. y_default_accel .. " name " .. entity.animals_name .. " at: " .. printpos(entity.object:getpos()))
--end
dbg_animals.movement_lvl1("ANIMALS: setting acceleration to " ..printpos(movement_state.accel_to_set) )
dbg_animals.pmovement_lvl1("ANIMALS: setting acceleration to " ..printpos(movement_state.accel_to_set) )
entity.dynamic_data.movement.acceleration = movement_state.accel_to_set
entity.object:setacceleration(movement_state.accel_to_set)
end
@ -245,7 +244,7 @@ function movement_gen.callback(entity,now)
)
if math.random() < start_chance then
dbg_animals.movement_lvl2("ANIMALS: animal starts to move, chance was:" .. start_chance ..
dbg_animals.pmovement_lvl2("ANIMALS: animal starts to move, chance was:" .. start_chance ..
" deltatime was: " .. delta_t ..
" entity:", entity)
@ -263,7 +262,7 @@ function movement_gen.callback(entity,now)
--random chance of stopping
if math.random() < stop_chance then
dbg_animals.movement_lvl2("ANIMALS: animal stops to move, chance was:" .. stop_chance ..
dbg_animals.pmovement_lvl2("ANIMALS: animal stops to move, chance was:" .. stop_chance ..
" deltatime was: " .. delta_t ..
" entity:", entity)
@ -277,6 +276,7 @@ function movement_gen.callback(entity,now)
entity.dynamic_data.movement.moving = false
entity.dynamic_data.movement.ts_state_changed = now
else
dbg_animals.pmovement_lvl2("ANIMALS: " .. entity.data.name .. " calling movement callback")
movement_gen.generator(entity)
end
end
@ -336,6 +336,7 @@ function movement_gen.fix_runaway(entity,movement_state)
math.exp(movement_state.current_velocity.z,2))
if xzspeed > entity.data.movement.max_speed then
dbg_animals.pmovement_lvl3("ANIMALS: too fast! vxz=" .. xzspeed)
local newaccel = {x=0,y=movement_state.current_acceleration.y,z=0}
--calculate sign of acceleration
@ -378,11 +379,19 @@ end
-- retval: -
-------------------------------------------------------------------------------
function movement_gen.fix_to_slow(entity,movement_state)
local xzspeed = math.sqrt(math.pow(movement_state.current_velocity.x,2) +
math.pow(movement_state.current_velocity.z,2) )
dbg_animals.pmovement_lvl3("ANIMALS: x=" .. movement_state.current_velocity.x ..
" z=" ..movement_state.current_velocity.z ..
" xz=" .. xzspeed)
--this ain't perfect to avoid flying animals standing in air
--but it's a quick solution to fix most of the problems
if entity.data.movement.min_speed ~= nil and
xzspeed < entity.data.movement.min_speed then
dbg_animals.pmovement_lvl3("ANIMALS: too slow! vxz=" .. xzspeed)
--use normal speed change handling
movement_state.force_change = true
end

View File

@ -18,7 +18,7 @@ local stop_and_go_prototype = {
random_jump_chance =0,
random_jump_initial_speed =0,
random_jump_delay =0,
random_acceleration_change =0.05,
random_acceleration_change =0.1,
movement_canfly =false,

View File

@ -18,7 +18,7 @@ local stop_and_go_meadow_prototype = {
random_jump_chance =0,
random_jump_initial_speed =0,
random_jump_delay =0,
random_acceleration_change =0.05,
random_acceleration_change =0.1,
movement_canfly =false,

View File

@ -290,6 +290,28 @@ function movement_generic.fix_current_pos(entity,movement_state)
return { abort_processing=abort_processing, }
end
function update_orientation_simple(entity,current_velocity)
local x_abs = math.abs(current_velocity.x)
local z_abs = math.abs(current_velocity.z)
if x_abs > z_abs then
if current_velocity.x > 0 then
set_yaw(entity,0)
--entity.object:setyaw(0)
else
set_yaw(entity,3.14)
--entity.object:setyaw(3.14)
end
else
if current_velocity.z >0 then
set_yaw(entity,1.57)
--entity.object:setyaw(1.57)
else
set_yaw(entity,4.71)
--entity.object:setyaw(4.71)
end
end
end
-------------------------------------------------------------------------------
-- name: update_orientation(entity)
--
@ -302,32 +324,52 @@ function update_orientation(entity,now)
local new_orientation = 0
if entity.dynamic_data.movement.ts_orientation_upd + 1 < now and
entity.dynamic_data.movement.moving then
-- if entity.dynamic_data.movement.ts_orientation_upd + 1 < now and
if entity.dynamic_data.movement.moving then
entity.dynamic_data.movement.ts_orientation_upd = now
dbg_animals.movement_lvl3("ANIMALS: Updating orientation")
--entity.dynamic_data.movement.ts_orientation_upd = now
current_velocity = get_velocity(entity)
--current_velocity = entity.object:getvelocity()
local current_velocity = get_velocity(entity)
local acceleration = entity.object:getacceleration()
local pos = entity.getbasepos(entity)
--predict position animal will be in 0.25 seconds
local predicted_pos = {x=pos.x,y=pos.y,z=pos.z}
local x_abs = math.abs(current_velocity.x)
local z_abs = math.abs(current_velocity.z)
predicted_pos.x = predicted_pos.x + current_velocity.x * 0.25 + (acceleration.x/2)*math.exp(0.25,2)
predicted_pos.z = predicted_pos.z + current_velocity.z * 0.25 + (acceleration.z/2)*math.exp(0.25,2)
local delta_x = predicted_pos.x - pos.x
local delta_z = predicted_pos.z - pos.z
if x_abs > z_abs then
if current_velocity.x > 0 then
set_yaw(entity,0)
--entity.object:setyaw(0)
else
set_yaw(entity,3.14)
--entity.object:setyaw(3.14)
end
--legacy 2d mode
if (entity.data.graphics.visual == "sprite") then
update_orientation_simple(entity,{x=delta_x, z=delta_z})
-- 3d mode
else
if current_velocity.z >0 then
set_yaw(entity,1.57)
--entity.object:setyaw(1.57)
--predict position animal will be in 0.5 seconds
if (delta_x ~= 0 ) and
(delta_z ~= 0) then
local direction = 0
if ( delta_x > 0 and delta_z > 0 ) or
(delta_x < 0 and delta_z < 0) then
direction = math.atan2(delta_x,delta_z)
else
direction = math.atan2(delta_x * -1,delta_z * -1)
end
set_yaw (entity,direction)
dbg_animals.movement_lvl2("ANIMALS: x-delta: " .. delta_x .. " z-delta: " .. delta_z .. " direction: " .. direction)
elseif (delta_x ~= 0) or
(delta_z ~= 0) then
dbg_animals.movement_lvl2("ANIMALS: at least speed for one direction is 0")
update_orientation_simple(entity,{x=delta_x,z=delta_z})
else
set_yaw(entity,4.71)
--entity.object:setyaw(4.71)
dbg_animals.movement_lvl3("ANIMALS: not moving")
end
end
end

View File

@ -1,3 +1,7 @@
#cleanup via find
#
#
# find . -name .svn -exec rm -r {} \;
rm -rf animal_big_red/.svn
rm -rf animal_big_red/textures/.svn
rm -rf animal_chicken/.svn

View File

@ -1,10 +1,13 @@
local version = "0.0.2"
local version = "0.0.3"
local modpath = minetest.get_modpath("barn")
--include debug trace functions
dofile (modpath .. "/model.lua")
minetest.register_craftitem("barn:barn_empty", {
description = "Barn to breed animals",
image = minetest.inventorycube("barn_empty_top.png","barn_empty_side.png","barn_empty_side.png"),
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
@ -44,9 +47,9 @@ minetest.register_entity(":barn:barn_ent",
{
physical = true,
collisionbox = {-0.5,-0.5,-0.5, 0.5,0.5,0.5},
visual = "cube",
textures = {"barn_top.png","barn_bottom.png",
"barn_side.png","barn_side.png","barn_side.png","barn_side.png"},
visual = "wielditem",
textures = { "barn:box_filled"},
visual_size = { x=0.666,y=0.666,z=0.666},
on_step = function(self,dtime)
@ -146,9 +149,9 @@ minetest.register_entity(":barn:barn_empty_ent",
{
physical = true,
collisionbox = {-0.5,-0.5,-0.5, 0.5,0.5,0.5},
visual = "cube",
textures = {"barn_empty_top.png","barn_empty_bottom.png",
"barn_empty_side.png","barn_empty_side.png","barn_empty_side.png","barn_empty_side.png"},
visual = "wielditem",
textures = { "barn:box_empty"},
visual_size = { x=0.666,y=0.666,z=0.666},
on_punch = function(self,player)

187
mods/animals/barn/model.lua Normal file
View File

@ -0,0 +1,187 @@
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_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_bottom.png",
"barn_3d_filled_top.png",
"barn_3d_filled_side.png",
"barn_3d_filled_side.png",
"barn_3d_filled_side.png",
"barn_3d_filled_side.png",
}
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
},
})

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

View File

@ -80,7 +80,7 @@ minetest.register_node("trap:cought_vombie", {
description = "Trap containing vombie",
tile_images = {"trap_cought_vombie.png"},
drawtype = "normal",
material = minetest.digprop_constanttime(5),
groups = { snappy=3 },
drop = "animal_vombie:vombie",
light_source = 2,
})

View File

@ -11,7 +11,7 @@ PLANTS = {
PLANTLIKE = function(nodeid, nodename,type,option)
if option == nil then option = false end
local params ={ description = nodename, drawtype = "plantlike", tiles = {"hydro_"..nodeid..'.png'},
local params ={ description = nodename, drawtype = "plantlike", tile_images = {"hydro_"..nodeid..'.png'},
inventory_image = "hydro_"..nodeid..'.png', wield_image = "hydro_"..nodeid..'.png', paramtype = "light", }
if type == 'veg' then
@ -43,7 +43,7 @@ GLOWLIKE = function(nodeid,nodename,drawtype)
minetest.register_node("hydro:"..nodeid, {
description = nodename,
drawtype = drawtype,
tiles = {"hydro_"..nodeid..".png"},
tile_images = {"hydro_"..nodeid..".png"},
inventory_image = inv_image,
light_propagates = true,
paramtype = "light",
@ -60,14 +60,14 @@ PLANTLIKE('coffeecup','Coffee Cup','eat',2)
GLOWLIKE('growlamp','Growlamp','plantlike')
minetest.register_node("hydro:promix", {
description = "Promix",
tiles = {"hydro_promix.png"},
tile_images = {"hydro_promix.png"},
is_ground_content = true,
groups = {crumbly=3},
sounds = default.node_sound_dirt_defaults(),
})
minetest.register_node("hydro:roastedcoffee", {
description = "Roasted Coffee",
tiles = {"hydro_roastedcoffee.png"},
tile_images = {"hydro_roastedcoffee.png"},
inventory_image = minetest.inventorycube("hydro_roastedcoffee.png"),
is_ground_content = true,
groups = {snappy=2,cracky=3,oddly_breakable_by_hand=3},
@ -77,7 +77,7 @@ minetest.register_node("hydro:rosebush", {
description = "Rose Bush",
drawtype = "allfaces_optional",
visual_scale = 1.3,
tiles = {"hydro_rosebush.png"},
tile_images = {"hydro_rosebush.png"},
paramtype = "light",
groups = {snappy=3, flammable=2},
sounds = default.node_sound_leaves_defaults(),
@ -99,7 +99,7 @@ for index,plant in pairs(PLANTS) do
description = "Wild Plant",
drawtype = "plantlike",
visual_scale = 1.0,
tiles = {"hydro_wildplant.png"},
tile_images = {"hydro_wildplant.png"},
paramtype = "light",
walkable = false,
groups = {snappy=3,flammable=3},
@ -113,7 +113,7 @@ for index,plant in pairs(PLANTS) do
minetest.register_node("hydro:seeds_"..plant.name, {
description = plant.name.." Seeds",
drawtype = "signlike",
tiles = {"hydro_seeds.png"},
tile_images = {"hydro_seeds.png"},
inventory_image = "hydro_seeds.png",
wield_image = "hydro_seeds.png",
paramtype = "light",
@ -134,7 +134,7 @@ for index,plant in pairs(PLANTS) do
minetest.register_node('hydro:seedlings_'..plant.name, {
drawtype = 'plantlike',
visual_scale = 1.0,
tiles = { 'hydro_seedlings.png' },
tile_images = { 'hydro_seedlings.png' },
inventory_image = 'hydro_seedlings.png',
sunlight_propagates = true,
paramtype = 'light',
@ -147,7 +147,7 @@ for index,plant in pairs(PLANTS) do
minetest.register_node('hydro:sproutlings_' .. plant.name, {
drawtype = 'plantlike',
visual_scale = 1.0,
tiles = { 'hydro_sproutlings.png' },
tile_images = { 'hydro_sproutlings.png' },
inventory_image = 'hydro_sproutlings.png',
sunlight_propagates = true,
paramtype = 'light',
@ -161,7 +161,7 @@ for index,plant in pairs(PLANTS) do
description = 'Tomato Plant (Young)',
drawtype = 'plantlike',
visual_scale = 1.0,
tiles = { 'hydro_'..plant.name..'1.png' },
tile_images = { 'hydro_'..plant.name..'1.png' },
inventory_image = 'hydro_'..plant.name..'1.png',
sunlight_propagates = true,
paramtype = 'light',
@ -171,18 +171,20 @@ for index,plant in pairs(PLANTS) do
sounds = default.node_sound_leaves_defaults(),
drop = '',
})
local ondig = nil
local after_dig_node = nil
if plant.growtype == 'permaculture' then
plant.growtype = 'growshort'
ondig = function(pos,node)
after_dig_node = function(pos,node)
minetest.env:add_node(pos,{type='node',name='hydro:'..plant.name..'1'})
end
end
minetest.register_node('hydro:'..plant.name..'2', {
description = 'Tomato Plant (Youngish)',
drawtype = 'plantlike',
visual_scale = 1.0,
tiles = { 'hydro_'..plant.name..'2.png' },
tile_images = { 'hydro_'..plant.name..'2.png' },
inventory_image = 'hydro_'..plant.name..'2.png',
sunlight_propagates = true,
paramtype = 'light',
@ -190,14 +192,13 @@ for index,plant in pairs(PLANTS) do
furnace_burntime = 1,
groups = { snappy = 3 },
sounds = default.node_sound_leaves_defaults(),
on_dig = ondig,
drop = '',
})
minetest.register_node('hydro:'..plant.name..'3', {
description = 'Tomato Plant (Fruitings)',
drawtype = 'plantlike',
visual_scale = 1.0,
tiles = { 'hydro_'..plant.name..'3.png' },
tile_images = { 'hydro_'..plant.name..'3.png' },
inventory_image = 'hydro_'..plant.name..'3.png',
sunlight_propagates = true,
paramtype = 'light',
@ -205,17 +206,18 @@ for index,plant in pairs(PLANTS) do
furnace_burntime = 1,
groups = { snappy = 3 },
sounds = default.node_sound_leaves_defaults(),
on_dig = ondig,
drop = '',
})
local harvest = 'hydro:'..plant.name
if plant.give_on_harvest ~= nil then harvest = plant.give_on_harvest end
if plant.give_on_harvest then harvest = plant.give_on_harvest end
minetest.register_node('hydro:'..plant.name..'4', {
description = 'Tomato Plant (Ripe)',
drawtype = 'plantlike',
visual_scale = 1.0,
tiles = { 'hydro_'..plant.name..'4.png' },
tile_images = { 'hydro_'..plant.name..'4.png' },
inventory_image = 'hydro_'..plant.name..'4.png',
sunlight_propagates = true,
paramtype = 'light',
@ -223,14 +225,14 @@ for index,plant in pairs(PLANTS) do
furnace_burntime = 1,
groups = { snappy = 3 },
sounds = default.node_sound_leaves_defaults(),
on_dig = ondig,
after_dig_node = after_dig_node,
drop = {
items = {
{ items = {'hydro:seeds_'..plant.name..' 4'},
rarity = 6,
rarity = 4,
},
{
items = {harvest..' 4'},
items = {harvest..' 2'},
}
}
},
@ -241,7 +243,7 @@ for index,plant in pairs(PLANTS) do
description = plant.name,
drawtype = "plantlike",
visual_scale = 1.0,
tiles = {"hydro_"..plant.name..".png"},
tile_images = {"hydro_"..plant.name..".png"},
inventory_image = "hydro_"..plant.name..".png",
paramtype = "light",
sunlight_propagates = true,
@ -440,9 +442,9 @@ minetest.register_craft({ output = 'hydro:promix 6', recipe = {
{'default:dirt', 'default:dirt', 'default:dirt'},
}})
minetest.register_craft({ output = 'hydro:wine 1', recipe = {
{'default:glass', 'hydro:hydroponics_grapes','default:glass'},
{'default:glass', 'hydro:hydroponics_grapes','default:glass'},
{'default:glass', 'hydro:hydroponics_grapes','default:glass'},
{'default:glass', 'hydro:grapes','default:glass'},
{'default:glass', 'hydro:grapes','default:glass'},
{'default:glass', 'hydro:grapes','default:glass'},
}})
minetest.register_craft({ output = 'node "hydro:coffeecup" 1', recipe = {
{'','',''},

View File

@ -67,8 +67,8 @@ minetest.register_node("hydro:promix", {
})
minetest.register_node("hydro:roastedcoffee", {
description = "Roasted Coffee",
tile_images = {"hydro_coffee.png"},
inventory_image = minetest.inventorycube("hydro_coffee.png"),
tile_images = {"hydro_roastedcoffee.png"},
inventory_image = minetest.inventorycube("hydro_roastedcoffee.png"),
is_ground_content = true,
groups = {snappy=2,cracky=3,oddly_breakable_by_hand=3},
sounds = default.node_sound_stone_defaults(),
@ -171,12 +171,14 @@ for index,plant in pairs(PLANTS) do
sounds = default.node_sound_leaves_defaults(),
drop = '',
})
local ondig = nil
local after_dig_node = nil
if plant.growtype == 'permaculture' then
plant.growtype = 'growshort'
ondig = function(pos,node)
after_dig_node = function(pos,node)
minetest.env:add_node(pos,{type='node',name='hydro:'..plant.name..'1'})
end
end
minetest.register_node('hydro:'..plant.name..'2', {
description = 'Tomato Plant (Youngish)',
@ -190,7 +192,6 @@ for index,plant in pairs(PLANTS) do
furnace_burntime = 1,
groups = { snappy = 3 },
sounds = default.node_sound_leaves_defaults(),
on_dig = ondig,
drop = '',
})
minetest.register_node('hydro:'..plant.name..'3', {
@ -205,11 +206,12 @@ for index,plant in pairs(PLANTS) do
furnace_burntime = 1,
groups = { snappy = 3 },
sounds = default.node_sound_leaves_defaults(),
on_dig = ondig,
drop = '',
})
local harvest = 'hydro:'..plant.name
if plant.give_on_harvest ~= nil then harvest = plant.give_on_harvest end
if plant.give_on_harvest then harvest = plant.give_on_harvest end
minetest.register_node('hydro:'..plant.name..'4', {
description = 'Tomato Plant (Ripe)',
@ -223,14 +225,14 @@ for index,plant in pairs(PLANTS) do
furnace_burntime = 1,
groups = { snappy = 3 },
sounds = default.node_sound_leaves_defaults(),
on_dig = ondig,
after_dig_node = after_dig_node,
drop = {
items = {
{ items = {'hydro:seeds_'..plant.name..' 4'},
rarity = 6,
rarity = 4,
},
{
items = {harvest..' 4'},
items = {harvest..' 2'},
}
}
},