mirror of
https://git.minetest.land/VoxeLibre/VoxeLibre.git
synced 2024-11-04 23:31:05 +01:00
add flowerpots API
This commit is contained in:
parent
134005180c
commit
7b5d67cdbe
8 changed files with 200 additions and 172 deletions
|
@ -1 +1 @@
|
|||
name = mcl_core
|
||||
name = mcl_core
|
|
@ -1,5 +0,0 @@
|
|||
mcl_core
|
||||
mcl_sounds
|
||||
mcl_farming
|
||||
mcl_flowers
|
||||
doc?
|
|
@ -1,4 +1,8 @@
|
|||
local S = minetest.get_translator("mcl_flowerpots")
|
||||
local has_doc = minetest.get_modpath("doc")
|
||||
|
||||
mcl_flowerpots = {}
|
||||
mcl_flowerpots.registered_pots = {}
|
||||
|
||||
local flowers = {
|
||||
{"dandelion", "mcl_flowers:dandelion", S("Dandelion Flower Pot")},
|
||||
|
@ -23,10 +27,6 @@ local flowers = {
|
|||
{"fern", "mcl_flowers:fern", S("Fern Flower Pot"), {"mcl_flowers_fern_inv.png"}},
|
||||
}
|
||||
|
||||
local cubes = {
|
||||
{"cactus", "mcl_core:cactus", S("Cactus Flower Pot")},
|
||||
}
|
||||
|
||||
minetest.register_node("mcl_flowerpots:flower_pot", {
|
||||
description = S("Flower Pot"),
|
||||
_tt_help = S("Can hold a small flower or plant"),
|
||||
|
@ -62,24 +62,10 @@ minetest.register_node("mcl_flowerpots:flower_pot", {
|
|||
return
|
||||
end
|
||||
local item = clicker:get_wielded_item():get_name()
|
||||
for _, row in ipairs(flowers) do
|
||||
local flower = row[1]
|
||||
local flower_node = row[2]
|
||||
if item == flower_node then
|
||||
minetest.swap_node(pos, {name="mcl_flowerpots:flower_pot_"..flower})
|
||||
if not minetest.is_creative_enabled(clicker:get_player_name()) then
|
||||
itemstack:take_item()
|
||||
end
|
||||
end
|
||||
end
|
||||
for _, row in ipairs(cubes) do
|
||||
local flower = row[1]
|
||||
local flower_node = row[2]
|
||||
if item == flower_node then
|
||||
minetest.swap_node(pos, {name="mcl_flowerpots:flower_pot_"..flower})
|
||||
if not minetest.is_creative_enabled(clicker:get_player_name()) then
|
||||
itemstack:take_item()
|
||||
end
|
||||
if mcl_flowerpots.registered_pots[item] then
|
||||
minetest.swap_node(pos, {name="mcl_flowerpots:flower_pot_"..mcl_flowerpots.registered_pots[item]})
|
||||
if not minetest.is_creative_enabled(clicker:get_player_name()) then
|
||||
itemstack:take_item()
|
||||
end
|
||||
end
|
||||
end,
|
||||
|
@ -94,112 +80,106 @@ minetest.register_craft({
|
|||
}
|
||||
})
|
||||
|
||||
for _, row in ipairs(flowers) do
|
||||
local flower = row[1]
|
||||
local flower_node = row[2]
|
||||
local desc = row[3]
|
||||
local texture
|
||||
if row[4] then
|
||||
texture = row[4]
|
||||
else
|
||||
texture = minetest.registered_nodes[flower_node]["tiles"]
|
||||
function mcl_flowerpots.register_potted_flower(name, def)
|
||||
mcl_flowerpots.registered_pots[name] = def.name
|
||||
minetest.register_node(":mcl_flowerpots:flower_pot_"..def.name, {
|
||||
description = def.desc.." "..S("Flower Pot"),
|
||||
_doc_items_create_entry = false,
|
||||
drawtype = "mesh",
|
||||
mesh = "flowerpot.obj",
|
||||
tiles = {
|
||||
"[combine:32x32:0,0=mcl_flowerpots_flowerpot.png:0,0="..def.image,
|
||||
},
|
||||
use_texture_alpha = minetest.features.use_texture_alpha_string_modes and "clip" or true,
|
||||
visual_scale = 0.5,
|
||||
wield_scale = {x=1.0, y=1.0, z=1.0},
|
||||
paramtype = "light",
|
||||
sunlight_propagates = true,
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
fixed = {-0.2, -0.5, -0.2, 0.2, -0.1, 0.2}
|
||||
},
|
||||
collision_box = {
|
||||
type = "fixed",
|
||||
fixed = {-0.2, -0.5, -0.2, 0.2, -0.1, 0.2}
|
||||
},
|
||||
is_ground_content = false,
|
||||
groups = {dig_immediate=3, attached_node=1, dig_by_piston=1, not_in_creative_inventory=1, flower_pot=2},
|
||||
sounds = mcl_sounds.node_sound_stone_defaults(),
|
||||
on_rightclick = function(pos, item, clicker)
|
||||
local player_name = clicker:get_player_name()
|
||||
if minetest.is_protected(pos, player_name) then
|
||||
minetest.record_protection_violation(pos, player_name)
|
||||
return
|
||||
end
|
||||
minetest.add_item({x=pos.x, y=pos.y+0.5, z=pos.z}, name)
|
||||
minetest.set_node(pos, {name="mcl_flowerpots:flower_pot"})
|
||||
end,
|
||||
drop = {
|
||||
items = {
|
||||
{ items = { "mcl_flowerpots:flower_pot", name } }
|
||||
}
|
||||
},
|
||||
})
|
||||
-- Add entry alias for the Help
|
||||
if has_doc then
|
||||
doc.add_entry_alias("nodes", "mcl_flowerpots:flower_pot", "nodes", "mcl_flowerpots:flower_pot_"..name)
|
||||
end
|
||||
end
|
||||
minetest.register_node("mcl_flowerpots:flower_pot_"..flower, {
|
||||
description = desc,
|
||||
_doc_items_create_entry = false,
|
||||
drawtype = "mesh",
|
||||
mesh = "flowerpot.obj",
|
||||
tiles = {
|
||||
"[combine:32x32:0,0=mcl_flowerpots_flowerpot.png:0,0="..texture[1],
|
||||
},
|
||||
use_texture_alpha = minetest.features.use_texture_alpha_string_modes and "clip" or true,
|
||||
visual_scale = 0.5,
|
||||
wield_scale = {x=1.0, y=1.0, z=1.0},
|
||||
paramtype = "light",
|
||||
sunlight_propagates = true,
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
fixed = {-0.2, -0.5, -0.2, 0.2, -0.1, 0.2}
|
||||
},
|
||||
collision_box = {
|
||||
type = "fixed",
|
||||
fixed = {-0.2, -0.5, -0.2, 0.2, -0.1, 0.2}
|
||||
},
|
||||
is_ground_content = false,
|
||||
groups = {dig_immediate=3, attached_node=1, dig_by_piston=1, not_in_creative_inventory=1, flower_pot=2},
|
||||
sounds = mcl_sounds.node_sound_stone_defaults(),
|
||||
on_rightclick = function(pos, item, clicker)
|
||||
local name = clicker:get_player_name()
|
||||
if minetest.is_protected(pos, name) then
|
||||
minetest.record_protection_violation(pos, name)
|
||||
return
|
||||
end
|
||||
minetest.add_item({x=pos.x, y=pos.y+0.5, z=pos.z}, flower_node)
|
||||
minetest.set_node(pos, {name="mcl_flowerpots:flower_pot"})
|
||||
end,
|
||||
drop = {
|
||||
items = {
|
||||
{ items = { "mcl_flowerpots:flower_pot", flower_node } }
|
||||
}
|
||||
},
|
||||
|
||||
function mcl_flowerpots.register_potted_cube(name, def)
|
||||
mcl_flowerpots.registered_pots[name] = def.name
|
||||
minetest.register_node(":mcl_flowerpots:flower_pot_"..def.name, {
|
||||
description = def.desc.." "..S("Flower Pot"),
|
||||
_doc_items_create_entry = false,
|
||||
drawtype = "mesh",
|
||||
mesh = "flowerpot_with_long_cube.obj",
|
||||
tiles = {
|
||||
"[combine:32x32:0,0=mcl_flowerpots_flowerpot.png:0,0="..def.image,
|
||||
},
|
||||
use_texture_alpha = minetest.features.use_texture_alpha_string_modes and "clip" or true,
|
||||
visual_scale = 0.5,
|
||||
wield_scale = {x=1.0, y=1.0, z=1.0},
|
||||
paramtype = "light",
|
||||
sunlight_propagates = true,
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
fixed = {-0.2, -0.5, -0.2, 0.2, -0.1, 0.2}
|
||||
},
|
||||
collision_box = {
|
||||
type = "fixed",
|
||||
fixed = {-0.2, -0.5, -0.2, 0.2, -0.1, 0.2}
|
||||
},
|
||||
is_ground_content = false,
|
||||
groups = {dig_immediate=3, attached_node=1, dig_by_piston=1, not_in_creative_inventory=1, flower_pot=2},
|
||||
sounds = mcl_sounds.node_sound_stone_defaults(),
|
||||
on_rightclick = function(pos, item, clicker)
|
||||
local name = ""
|
||||
if clicker:is_player() then
|
||||
player_name = clicker:get_player_name()
|
||||
end
|
||||
if minetest.is_protected(pos, player_name) then
|
||||
minetest.record_protection_violation(pos, player_name)
|
||||
return
|
||||
end
|
||||
minetest.add_item({x=pos.x, y=pos.y+0.5, z=pos.z}, name)
|
||||
minetest.set_node(pos, {name="mcl_flowerpots:flower_pot"})
|
||||
end,
|
||||
drop = {
|
||||
items = {
|
||||
{ items = { "mcl_flowerpots:flower_pot", name } }
|
||||
}
|
||||
},
|
||||
})
|
||||
-- Add entry alias for the Help
|
||||
if has_doc then
|
||||
doc.add_entry_alias("nodes", "mcl_flowerpots:flower_pot", "nodes", "mcl_flowerpots:flower_pot_"..def.name)
|
||||
end
|
||||
end
|
||||
|
||||
--forced because hard dependency to mcl_core
|
||||
mcl_flowerpots.register_potted_cube("mcl_core:cactus", {
|
||||
name = "cactus",
|
||||
desc = S("Cactus"),
|
||||
image = "mcl_flowerpots_cactus.png",
|
||||
})
|
||||
-- Add entry alias for the Help
|
||||
if minetest.get_modpath("doc") then
|
||||
doc.add_entry_alias("nodes", "mcl_flowerpots:flower_pot", "nodes", "mcl_flowerpots:flower_pot_"..flower)
|
||||
end
|
||||
end
|
||||
|
||||
for _, row in ipairs(cubes) do
|
||||
local flower = row[1]
|
||||
local flower_node = row[2]
|
||||
local desc = row[3]
|
||||
minetest.register_node("mcl_flowerpots:flower_pot_"..flower, {
|
||||
description = desc,
|
||||
_doc_items_create_entry = false,
|
||||
drawtype = "mesh",
|
||||
mesh = "flowerpot_with_long_cube.obj",
|
||||
tiles = {
|
||||
"mcl_flowerpots_"..flower..".png",
|
||||
},
|
||||
use_texture_alpha = minetest.features.use_texture_alpha_string_modes and "clip" or true,
|
||||
visual_scale = 0.5,
|
||||
wield_scale = {x=1.0, y=1.0, z=1.0},
|
||||
paramtype = "light",
|
||||
sunlight_propagates = true,
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
fixed = {-0.2, -0.5, -0.2, 0.2, -0.1, 0.2}
|
||||
},
|
||||
collision_box = {
|
||||
type = "fixed",
|
||||
fixed = {-0.2, -0.5, -0.2, 0.2, -0.1, 0.2}
|
||||
},
|
||||
is_ground_content = false,
|
||||
groups = {dig_immediate=3, attached_node=1, dig_by_piston=1, not_in_creative_inventory=1, flower_pot=2},
|
||||
sounds = mcl_sounds.node_sound_stone_defaults(),
|
||||
on_rightclick = function(pos, item, clicker)
|
||||
local name = ""
|
||||
if clicker:is_player() then
|
||||
name = clicker:get_player_name()
|
||||
end
|
||||
if minetest.is_protected(pos, name) then
|
||||
minetest.record_protection_violation(pos, name)
|
||||
return
|
||||
end
|
||||
minetest.add_item({x=pos.x, y=pos.y+0.5, z=pos.z}, flower_node)
|
||||
minetest.set_node(pos, {name="mcl_flowerpots:flower_pot"})
|
||||
end,
|
||||
drop = {
|
||||
items = {
|
||||
{ items = { "mcl_flowerpots:flower_pot", flower_node } }
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
})
|
||||
|
||||
-- Add entry alias for the Help
|
||||
if minetest.get_modpath("doc") then
|
||||
doc.add_entry_alias("nodes", "mcl_flowerpots:flower_pot", "nodes", "mcl_flowerpots:flower_pot_"..flower)
|
||||
end
|
||||
end
|
||||
|
|
3
mods/ITEMS/mcl_flowerpots/mod.conf
Normal file
3
mods/ITEMS/mcl_flowerpots/mod.conf
Normal file
|
@ -0,0 +1,3 @@
|
|||
name=mcl_flowerpots
|
||||
depends=mcl_core, mcl_sounds, mcl_farming
|
||||
optional_depends=doc
|
|
@ -1,5 +0,0 @@
|
|||
mcl_core
|
||||
mcl_util
|
||||
mcl_sounds
|
||||
screwdriver?
|
||||
doc?
|
|
@ -1,5 +1,6 @@
|
|||
local S = minetest.get_translator("mcl_flowers")
|
||||
local mod_screwdriver = minetest.get_modpath("screwdriver") ~= nil
|
||||
local has_mcl_flowerpots = minetest.get_modpath("mcl_flowerpots")
|
||||
local modpath = minetest.get_modpath("mcl_flowers")
|
||||
|
||||
mcl_flowers = {}
|
||||
|
@ -53,48 +54,49 @@ local on_place_flower = mcl_util.generate_on_place_plant_function(function(pos,
|
|||
return ok, colorize
|
||||
end)
|
||||
|
||||
function mcl_flowers.register_simple_flower(name, desc, image, simple_selection_box)
|
||||
function mcl_flowers.register_simple_flower(name, def)
|
||||
local newname = "mcl_flowers:"..name
|
||||
if not def._mcl_silk_touch_drop then def._mcl_silk_touch_drop = nil end
|
||||
if not def.drop then def.drop = newname end
|
||||
mcl_flowers.registered_simple_flowers[newname] = {
|
||||
desc=desc
|
||||
image=image
|
||||
simple_selection_box=simple_selection_box
|
||||
name=name,
|
||||
desc=def.desc,
|
||||
pot_desc=def.pot_desc,
|
||||
image=def.image,
|
||||
selection_box=def.selection_box,
|
||||
}
|
||||
minetest.register_node(newname, {
|
||||
description = desc,
|
||||
description = def.desc,
|
||||
_doc_items_longdesc = smallflowerlongdesc,
|
||||
_doc_items_usagehelp = plant_usage_help,
|
||||
drawtype = "plantlike",
|
||||
waving = 1,
|
||||
tiles = { image..".png" },
|
||||
inventory_image = image..".png",
|
||||
wield_image = image..".png",
|
||||
tiles = { def.image },
|
||||
inventory_image = def.image,
|
||||
wield_image = def.image,
|
||||
sunlight_propagates = true,
|
||||
paramtype = "light",
|
||||
walkable = false,
|
||||
stack_max = 64,
|
||||
drop = def.drop,
|
||||
groups = {dig_immediate=3,flammable=2,fire_encouragement=60,fire_flammability=100,plant=1,flower=1,place_flowerlike=1,non_mycelium_plant=1,attached_node=1,dig_by_water=1,destroy_by_lava_flow=1,dig_by_piston=1,enderman_takable=1,deco_block=1},
|
||||
sounds = mcl_sounds.node_sound_leaves_defaults(),
|
||||
node_placement_prediction = "",
|
||||
on_place = on_place_flower,
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
fixed = simple_selection_box,
|
||||
fixed = def.selection_box,
|
||||
},
|
||||
_mcl_silk_touch_drop = def._mcl_silk_touch_drop,
|
||||
})
|
||||
if def.potted and has_mcl_flowerpots then
|
||||
mcl_flowerpots.register_potted_flower(newname, {
|
||||
name = name,
|
||||
desc = def.desc,
|
||||
image = def.image,
|
||||
})
|
||||
end
|
||||
end
|
||||
local add_simple_flower = mcl_flowers.register_simple_flower
|
||||
add_simple_flower("poppy", S("Poppy"), "mcl_flowers_poppy", { -5/16, -0.5, -5/16, 5/16, 5/16, 5/16 })
|
||||
add_simple_flower("dandelion", S("Dandelion"), "flowers_dandelion_yellow", { -4/16, -0.5, -4/16, 4/16, 3/16, 4/16 })
|
||||
add_simple_flower("oxeye_daisy", S("Oxeye Daisy"), "mcl_flowers_oxeye_daisy", { -4/16, -0.5, -4/16, 4/16, 4/16, 4/16 })
|
||||
add_simple_flower("tulip_orange", S("Orange Tulip"), "flowers_tulip", { -3/16, -0.5, -3/16, 3/16, 5/16, 3/16 })
|
||||
add_simple_flower("tulip_pink", S("Pink Tulip"), "mcl_flowers_tulip_pink", { -3/16, -0.5, -3/16, 3/16, 5/16, 3/16 })
|
||||
add_simple_flower("tulip_red", S("Red Tulip"), "mcl_flowers_tulip_red", { -3/16, -0.5, -3/16, 3/16, 6/16, 3/16 })
|
||||
add_simple_flower("tulip_white", S("White Tulip"), "mcl_flowers_tulip_white", { -3/16, -0.5, -3/16, 3/16, 4/16, 3/16 })
|
||||
add_simple_flower("allium", S("Allium"), "mcl_flowers_allium", { -3/16, -0.5, -3/16, 3/16, 6/16, 3/16 })
|
||||
add_simple_flower("azure_bluet", S("Azure Bluet"), "mcl_flowers_azure_bluet", { -5/16, -0.5, -5/16, 5/16, 3/16, 5/16 })
|
||||
add_simple_flower("blue_orchid", S("Blue Orchid"), "mcl_flowers_blue_orchid", { -5/16, -0.5, -5/16, 5/16, 7/16, 5/16 })
|
||||
|
||||
|
||||
local wheat_seed_drop = {
|
||||
max_items = 1,
|
||||
|
|
3
mods/ITEMS/mcl_flowers/mod.conf
Normal file
3
mods/ITEMS/mcl_flowers/mod.conf
Normal file
|
@ -0,0 +1,3 @@
|
|||
name=mcl_flowers
|
||||
depends=mcl_core, mcl_util, mcl_sounds
|
||||
optional_depends=screwdriver, doc, mcl_flowerpots
|
|
@ -1,12 +1,62 @@
|
|||
local S = minetest.get_translator("mcl_flowers")
|
||||
local add_simple_flower = mcl_flowers.register_simple_flower
|
||||
add_simple_flower("poppy", S("Poppy"), "mcl_flowers_poppy", { -5/16, -0.5, -5/16, 5/16, 5/16, 5/16 })
|
||||
add_simple_flower("dandelion", S("Dandelion"), "flowers_dandelion_yellow", { -4/16, -0.5, -4/16, 4/16, 3/16, 4/16 })
|
||||
add_simple_flower("oxeye_daisy", S("Oxeye Daisy"), "mcl_flowers_oxeye_daisy", { -4/16, -0.5, -4/16, 4/16, 4/16, 4/16 })
|
||||
add_simple_flower("tulip_orange", S("Orange Tulip"), "flowers_tulip", { -3/16, -0.5, -3/16, 3/16, 5/16, 3/16 })
|
||||
add_simple_flower("tulip_pink", S("Pink Tulip"), "mcl_flowers_tulip_pink", { -3/16, -0.5, -3/16, 3/16, 5/16, 3/16 })
|
||||
add_simple_flower("tulip_red", S("Red Tulip"), "mcl_flowers_tulip_red", { -3/16, -0.5, -3/16, 3/16, 6/16, 3/16 })
|
||||
add_simple_flower("tulip_white", S("White Tulip"), "mcl_flowers_tulip_white", { -3/16, -0.5, -3/16, 3/16, 4/16, 3/16 })
|
||||
add_simple_flower("allium", S("Allium"), "mcl_flowers_allium", { -3/16, -0.5, -3/16, 3/16, 6/16, 3/16 })
|
||||
add_simple_flower("azure_bluet", S("Azure Bluet"), "mcl_flowers_azure_bluet", { -5/16, -0.5, -5/16, 5/16, 3/16, 5/16 })
|
||||
add_simple_flower("blue_orchid", S("Blue Orchid"), "mcl_flowers_blue_orchid", { -5/16, -0.5, -5/16, 5/16, 7/16, 5/16 })
|
||||
|
||||
mcl_flowers.register_simple_flower("poppy", {
|
||||
desc = S("Poppy"),
|
||||
image = "mcl_flowers_poppy.png",
|
||||
selection_box = { -5/16, -0.5, -5/16, 5/16, 5/16, 5/16 },
|
||||
potted = true,
|
||||
})
|
||||
mcl_flowers.register_simple_flower("dandelion", {
|
||||
desc = S("Dandelion"),
|
||||
image = "flowers_dandelion_yellow.png",
|
||||
selection_box = { -4/16, -0.5, -4/16, 4/16, 3/16, 4/16 },
|
||||
potted = true,
|
||||
})
|
||||
mcl_flowers.register_simple_flower("oxeye_daisy", {
|
||||
desc = S("Oxeye Daisy"),
|
||||
image = "mcl_flowers_oxeye_daisy.png",
|
||||
selection_box = { -4/16, -0.5, -4/16, 4/16, 4/16, 4/16 },
|
||||
potted = true,
|
||||
})
|
||||
mcl_flowers.register_simple_flower("tulip_orange", {
|
||||
desc = S("Orange Tulip"),
|
||||
image = "flowers_tulip.png",
|
||||
selection_box = { -3/16, -0.5, -3/16, 3/16, 5/16, 3/16 },
|
||||
potted = true,
|
||||
})
|
||||
mcl_flowers.register_simple_flower("tulip_pink", {
|
||||
desc = S("Pink Tulip"),
|
||||
image = "mcl_flowers_tulip_pink.png",
|
||||
selection_box = { -3/16, -0.5, -3/16, 3/16, 5/16, 3/16 },
|
||||
potted = true,
|
||||
})
|
||||
mcl_flowers.register_simple_flower("tulip_red", {
|
||||
desc = S("Red Tulip"),
|
||||
image = "mcl_flowers_tulip_red.png",
|
||||
selection_box = { -3/16, -0.5, -3/16, 3/16, 6/16, 3/16 },
|
||||
potted = true,
|
||||
})
|
||||
mcl_flowers.register_simple_flower("tulip_white", {
|
||||
desc = S("White Tulip"),
|
||||
image = "mcl_flowers_tulip_white.png",
|
||||
selection_box = { -3/16, -0.5, -3/16, 3/16, 4/16, 3/16 },
|
||||
potted = true,
|
||||
})
|
||||
mcl_flowers.register_simple_flower("allium", {
|
||||
desc = S("Allium"),
|
||||
image = "mcl_flowers_allium.png",
|
||||
selection_box = { -3/16, -0.5, -3/16, 3/16, 6/16, 3/16 },
|
||||
potted = true,
|
||||
})
|
||||
mcl_flowers.register_simple_flower("azure_bluet", {
|
||||
desc = S("Azure Bluet"),
|
||||
image = "mcl_flowers_azure_bluet.png",
|
||||
selection_box = { -5/16, -0.5, -5/16, 5/16, 3/16, 5/16 },
|
||||
potted = true,
|
||||
})
|
||||
mcl_flowers.register_simple_flower("blue_orchid", {
|
||||
desc = S("Blue Orchid"),
|
||||
image = "mcl_flowers_blue_orchid.png",
|
||||
selection_box = { -5/16, -0.5, -5/16, 5/16, 7/16, 5/16 },
|
||||
potted = true,
|
||||
})
|
Loading…
Reference in a new issue