add potats
parent
89ed4bd904
commit
1cd0375354
|
@ -9,4 +9,6 @@ pmb_flora = {}
|
|||
dofile(mod_path .. DIR_DELIM .. "nodes" .. DIR_DELIM .. "mushrooms.lua")
|
||||
dofile(mod_path .. DIR_DELIM .. "nodes" .. DIR_DELIM .. "grass.lua")
|
||||
dofile(mod_path .. DIR_DELIM .. "nodes" .. DIR_DELIM .. "flowers.lua")
|
||||
|
||||
dofile(mod_path .. DIR_DELIM .. "nodes" .. DIR_DELIM .. "flax.lua")
|
||||
dofile(mod_path .. DIR_DELIM .. "nodes" .. DIR_DELIM .. "potato.lua")
|
||||
|
|
|
@ -0,0 +1,130 @@
|
|||
local mod_name = minetest.get_current_modname()
|
||||
local S = minetest.get_translator(mod_name)
|
||||
|
||||
|
||||
local potato_box = {
|
||||
type = "fixed",
|
||||
fixed = {
|
||||
-6/16, -8/16, -6/16,
|
||||
6/16, -6/16, 6/16,
|
||||
}
|
||||
}
|
||||
|
||||
local potato_variants = {}
|
||||
|
||||
local drops = {
|
||||
full = {
|
||||
max_items = 4,
|
||||
items = {
|
||||
{
|
||||
items = {'pmb_flora:potato_seeds 1'},
|
||||
},
|
||||
{
|
||||
items = {'pmb_flora:potato_seeds 1'},
|
||||
rarity = 2
|
||||
},
|
||||
{
|
||||
items = {'pmb_flora:potato_seeds 2'},
|
||||
rarity = 2
|
||||
},
|
||||
},
|
||||
},
|
||||
partial = {
|
||||
max_items = 1,
|
||||
items = {
|
||||
{
|
||||
items = {'pmb_flora:potato_seeds'},
|
||||
rarity = 2
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
minetest.register_node("pmb_flora:potato_seeds", {
|
||||
description = S("Some potatoes"),
|
||||
inventory_image = "pmb_potato_seeds.png",
|
||||
wield_image = "pmb_potato_seeds.png",
|
||||
drawtype = "airlike",
|
||||
walkable = false,
|
||||
paramtype = "light",
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
fixed = {-0.1, -0.1, -0.1, 0.1, 0.1, 0.1},},
|
||||
is_ground_content = true,
|
||||
sunlight_propagates = true,
|
||||
groups = { item_copper_nugget = 1, craftitem = 1, copper = 1, nugget = 1, copper_nugget = 1, },
|
||||
after_place_node = function(pos, placer, itemstack, pointed_thing)
|
||||
minetest.set_node(pos, {name=potato_variants[1], param2 = 8})
|
||||
end,
|
||||
on_place = function(itemstack, placer, pointed_thing)
|
||||
return pmb_util.only_place_above(itemstack, placer, pointed_thing, {"soil"})
|
||||
end,
|
||||
})
|
||||
|
||||
local function register_potato(node_name)
|
||||
for i=1, 4 do
|
||||
local name = string.lower(node_name)
|
||||
local drop = (i == 4 and drops["full"]) or drops["partial"]
|
||||
local tiles = {"pmb_potato_" .. i .. ".png"}
|
||||
local growing = ((i ~= 4) and i) or 0
|
||||
potato_variants[#potato_variants+1] = 'pmb_flora:potato_' .. i
|
||||
minetest.register_node('pmb_flora:potato_' .. i, {
|
||||
description = "Some potato",
|
||||
drawtype = "plantlike",
|
||||
walkable = false,
|
||||
waving = 1,
|
||||
paramtype = "light",
|
||||
paramtype2 = "meshoptions",
|
||||
inventory_image = "pmb_potato_" .. i .. ".png",
|
||||
wield_image = "pmb_potato_" .. i .. ".png",
|
||||
is_ground_content = true,
|
||||
sunlight_propagates = true,
|
||||
selection_box = potato_box,
|
||||
groups = { attached_node = 1, item_potato_plant = 1, dig_immediate = 3, flora = 1, growth_stage = i, potato_growing = growing },
|
||||
_growth_stage = i,
|
||||
drop = drop,
|
||||
tiles = tiles,
|
||||
buildable_to = false,
|
||||
sounds = pmb_sounds.default_plant(),
|
||||
after_place_node = function(pos, placer, itemstack, pointed_thing)
|
||||
local variant = potato_variants[math.random(1, #potato_variants)]
|
||||
minetest.swap_node(pos, {name=variant, param2 = 8})
|
||||
end,
|
||||
})
|
||||
end
|
||||
end
|
||||
|
||||
-- 4 growth stages
|
||||
register_potato("potato_")
|
||||
|
||||
|
||||
|
||||
local function grow_potato(pos, node, active_object_count, active_object_count_wider)
|
||||
local light = minetest.get_node_light(pos, 0.5)
|
||||
if light > 8 then
|
||||
local next_stage = minetest.registered_nodes[node.name]._growth_stage + 1
|
||||
node.name = "pmb_flora:potato_" .. next_stage
|
||||
if not minetest.registered_nodes[node.name] then return false end
|
||||
|
||||
minetest.set_node(pos, node)
|
||||
end
|
||||
end
|
||||
|
||||
-- grow potato
|
||||
minetest.register_abm({
|
||||
nodenames = {'group:potato_growing'},
|
||||
interval = 10.0, --10
|
||||
chance = 50, --50
|
||||
action = grow_potato,
|
||||
})
|
||||
|
||||
-- grow potato faster near water?
|
||||
minetest.register_abm({
|
||||
nodenames = {'group:potato_growing'},
|
||||
neighbors = {"group:water"},
|
||||
interval = 10.0, --10
|
||||
chance = 40, --50
|
||||
action = grow_potato,
|
||||
})
|
||||
|
||||
|
Binary file not shown.
After Width: | Height: | Size: 617 B |
Binary file not shown.
After Width: | Height: | Size: 674 B |
Binary file not shown.
After Width: | Height: | Size: 764 B |
Binary file not shown.
After Width: | Height: | Size: 817 B |
Binary file not shown.
After Width: | Height: | Size: 829 B |
Binary file not shown.
After Width: | Height: | Size: 688 B |
Loading…
Reference in New Issue