flowerpots/nodes.lua

167 lines
5.4 KiB
Lua
Raw Normal View History

2017-02-02 13:41:44 -08:00
local flowers = {
2017-02-18 17:01:26 -08:00
{"lavender", "mapgen:lavender_flower", "Lavender"},
{"rose", "flowers:rose", "Rose"},
{"tulip", "flowers:tulip", "Tulip"},
{"geranium", "flowers:geranium", "Geranium"},
{"viola", "flowers:viola", "Viola"},
{"dandelion_yellow", "flowers:dandelion_yellow", "Yellow Dandelion"},
{"dandelion_white", "flowers:dandelion_white", "White Dandelion"},
2017-02-18 17:01:26 -08:00
{"flame_lily", "mapgen:flame_lily", "Flame Lily"},
{"mushroom_brown", "flowers:mushroom_brown", "Brown Mushroom"},
{"mushroom_red", "flowers:mushroom_red", "Red Mushroom"},
{"grass", "default:grass_1", "Grass"},
{"dry_grass", "default:dry_grass_1", "Dry Grass"},
{"dry_shrub", "default:dry_shrub", "Dry Shrub"},
{"papyrus", "default:papyrus", "Papyrus"},
2017-02-18 17:01:26 -08:00
{"small_cactus", "mapgen:small_cactus", "Small Cactus"},
{"small_cactus_1", "mapgen:small_cactus_1", "Small Cactus1"},
{"oxeye_daisy", "mapgen:oxeye_daisy", "Oxeye Daisy"},
{"dead_grass", "mapgen:dead_grass_5", "Dead Grass"},
{"jungle_grass", "mapgen:jungle_grass_5", "Jungle Grass"},
{"sapling", "default:sapling", "Sapling"},
{"acacia_sapling", "default:acacia_sapling", "Acacia Sapling"},
{"aspen_sapling", "default:aspen_sapling", "Aspen Sapling"},
{"junglesapling", "default:junglesapling", "Jungle Sapling"},
{"pine_sapling", "default:pine_sapling", "Pine Sapling"},
2017-02-12 06:17:39 -08:00
{"junglegrass", "default:junglegrass", "junglegrass"},
}
local cubes = {
{"cactus", "default:cactus", "Cactus"},
{"leaves", "default:leaves", "Leaves"},
{"aspen_leaves", "default:aspen_leaves", "Aspen Leaves"},
{"pine_needles", "default:pine_needles", "Pine Needles"},
{"jungleleaves", "default:jungleleaves", "Jungle Leaves"},
{"acacia_leaves", "default:acacia_leaves", "Acacia Leaves"},
2017-02-12 06:17:39 -08:00
{"bush_leaves", "default:bush_leaves", "Bush Leaves"},
{"acacia_bush_leaves", "default:acacia_bush_leaves", "Acacia Bush Leaves"},
2017-02-18 17:01:26 -08:00
{"willow_leaves", "mapgen:willow_leaves", "Willow Leaves"},
{"baobab_leaves", "mapgen:baobab_leaves", "Baobab Leaves"},
{"yellow_ipe_leaves", "mapgen:yellow_ipe_leaves", "Yellow Ipe Leaves"},
{"palm_leaves", "mapgen:palm_leaves", "Palm Leaves"},
2017-02-02 13:41:44 -08:00
}
minetest.register_node("flowerpots:flower_pot", {
description = "Flower Pot",
drawtype = "mesh",
mesh = "flowerpot.obj",
tiles = {
"flowerpot.png",
},
visual_scale = 0.5,
wield_scale = {x=1.0, y=1.0, z=1.0},
paramtype = "light",
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}
},
2017-02-11 16:23:44 -08:00
groups = {cracky = 1, oddly_breakable_by_hand = 1, attached_node=1},
2017-02-02 13:41:44 -08:00
sounds = default.node_sound_stone_defaults(),
on_rightclick = function(pos, node, clicker, itemstack)
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
2017-02-11 16:23:44 -08:00
minetest.set_node(pos, {name="flowerpots:flower_pot_"..flower})
if not minetest.setting_getbool("creative") then
2017-02-02 13:41:44 -08:00
itemstack:take_item()
2017-02-11 16:23:44 -08:00
end
2017-02-02 13:41:44 -08:00
end
end
for _, row in ipairs(cubes) do
local flower = row[1]
local flower_node = row[2]
if item == flower_node then
2017-02-11 16:23:44 -08:00
minetest.set_node(pos, {name="flowerpots:flower_pot_"..flower})
if not minetest.setting_getbool("creative") then
itemstack:take_item()
2017-02-11 16:23:44 -08:00
end
end
end
2017-02-02 13:41:44 -08:00
end,
})
2017-02-02 13:57:05 -08:00
minetest.register_craft({
output = 'flowerpots:flower_pot',
recipe = {
{'default:clay', 'default:dirt', 'default:clay'},
{'', 'default:clay', ''},
}
})
2017-02-02 13:41:44 -08:00
for _, row in ipairs(flowers) do
local flower = row[1]
local flower_node = row[2]
local desc = row[3]
local texture = minetest.registered_nodes[flower_node]["tiles"]
minetest.register_node("flowerpots:flower_pot_"..flower, {
2017-02-11 16:23:44 -08:00
description = "Flower Pot With "..desc.."",
drawtype = "mesh",
mesh = "flowerpot.obj",
tiles = {
"[combine:32x32:0,0=flowerpot.png:0,0="..texture[1],
},
visual_scale = 0.5,
wield_scale = {x=1.0, y=1.0, z=1.0},
paramtype = "light",
selection_box = {
type = "fixed",
2017-04-10 13:24:39 -07:00
fixed = {-0.2, -0.5, -0.2, 0.2, -0.1, 0.2},
},
collision_box = {
type = "fixed",
2017-04-10 13:24:39 -07:00
fixed = {-0.2, -0.5, -0.2, 0.2, -0.1, 0.2},
},
2017-02-11 16:23:44 -08:00
groups = {cracky = 1, oddly_breakable_by_hand = 1, not_in_creative_inventory=1, attached_node=1},
sounds = default.node_sound_stone_defaults(),
on_rightclick = function(pos, item, clicker)
2017-02-11 16:23:44 -08:00
minetest.add_item({x=pos.x, y=pos.y+0.5, z=pos.z}, flower_node)
minetest.set_node(pos, {name="flowerpots:flower_pot"})
end,
2017-02-11 16:23:44 -08:00
drop = {
max_items = 2,items = {{items = {"flowerpots:flower_pot", flower_node},rarity = 1,},},
},
})
end
for _, row in ipairs(cubes) do
local flower = row[1]
local flower_node = row[2]
2017-02-11 16:23:44 -08:00
local desc = row[3]
2017-02-02 13:41:44 -08:00
minetest.register_node("flowerpots:flower_pot_"..flower, {
2017-02-11 16:23:44 -08:00
description = "Flower Pot With "..desc.."",
2017-02-02 13:41:44 -08:00
drawtype = "mesh",
mesh = "flowerpot_with_long_cube.obj",
2017-02-02 13:41:44 -08:00
tiles = {
"flowerpot_"..flower..".png",
},
visual_scale = 0.5,
wield_scale = {x=1.0, y=1.0, z=1.0},
paramtype = "light",
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}
},
2017-02-11 16:23:44 -08:00
groups = {cracky = 1, oddly_breakable_by_hand = 1, not_in_creative_inventory=1, attached_node=1},
2017-02-02 13:41:44 -08:00
sounds = default.node_sound_stone_defaults(),
on_rightclick = function(pos, item, clicker)
2017-02-11 16:23:44 -08:00
minetest.add_item({x=pos.x, y=pos.y+0.5, z=pos.z}, flower_node)
minetest.set_node(pos, {name="flowerpots:flower_pot"})
2017-02-02 13:41:44 -08:00
end,
2017-02-11 16:23:44 -08:00
drop = {
max_items = 2,items = {{items = {"flowerpots:flower_pot", flower_node},rarity = 1,},},
},
2017-02-02 13:41:44 -08:00
})
end