Initial commit.

This commit is contained in:
Auke Kok 2017-02-02 14:45:53 -08:00
commit 1bc76c862b
10 changed files with 415 additions and 0 deletions

20
LICENSE Normal file
View File

@ -0,0 +1,20 @@
flowerpot - a minetest mod that adds a stylish flowerpot
See spdx.org/licenses to see what the License Identifiers used below mean.
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
All source code (lua):
(C) Auke Kok <sofar@foo-projects.org>
LGPL-2.1+
All models:
(C) Auke Kok <sofar@foo-projects.org>
CC-BY-SA-3.0
All Textures:
Public-Domain, see:
https://mods.curse.com/texture-packs/minecraft/227527-isabella-ii
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~

7
api.md Normal file
View File

@ -0,0 +1,7 @@
## flowerpot API
`flowerpot.register_node(name)` --[[
^ name = node name, e.g. "default:sapling"
^ the node must be defined and registered first using `minetest.register_node()`. ]]

3
depends.txt Normal file
View File

@ -0,0 +1,3 @@
default
farming
flowers

1
description.txt Normal file
View File

@ -0,0 +1 @@
A stylish flowerpot that can contain most plants.

164
init.lua Normal file
View File

@ -0,0 +1,164 @@
--[[
Copyright (C) 2015 - Auke Kok <sofar@foo-projects.org>
"flowerpot" is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of
the license, or (at your option) any later version.
--]]
flowerpot = {}
-- handle plant removal from flowerpot
local function flowerpot_on_punch(pos, node, puncher, pointed_thing)
if puncher and not minetest.check_player_privs(puncher, "protection_bypass") then
local name = puncher:get_player_name()
if minetest.is_protected(pos, name) then
minetest.record_protection_violation(pos, name)
return false
end
end
local nodedef = minetest.registered_nodes[node.name]
local plant = nodedef.flowerpot_plantname
assert(plant, "unknown plant in flowerpot: " .. node.name)
minetest.sound_play(nodedef.sounds.dug, {pos = pos})
minetest.handle_node_drops(pos, {plant}, puncher)
minetest.swap_node(pos, {name = "flowerpot:empty"})
end
-- handle plant insertion into flowerpot
local function flowerpot_on_rightclick(pos, node, clicker, itemstack, pointed_thing)
if clicker and not minetest.check_player_privs(clicker, "protection_bypass") then
local name = clicker:get_player_name()
if minetest.is_protected(pos, name) then
minetest.record_protection_violation(pos, name)
return false
end
end
local nodename = itemstack:get_name()
if not nodename then
return false
end
local name = "flowerpot:" .. nodename:gsub(":", "_")
local def = minetest.registered_nodes[name]
if not def then
return false
end
minetest.sound_play(def.sounds.place, {pos = pos})
minetest.swap_node(pos, {name = name})
if not minetest.setting_getbool("creative_mode") then
itemstack:take_item()
end
return itemstack
end
function flowerpot.register_node(nodename)
assert(nodename, "no nodename passed")
local nodedef = minetest.registered_nodes[nodename]
assert(nodedef, nodename .. " is not a known node")
local desc = nodedef.description
local name = nodedef.name:gsub(":", "_")
local tile = nodedef.tiles[1]
if type(tile) == "table" then
tile = tile.name
end
minetest.register_node("flowerpot:" .. name, {
description = "Flowerpot with " .. desc,
drawtype = "mesh",
mesh = "flowerpot.obj",
tiles = {
{name = "flowerpot.png"},
{name = tile},
},
paramtype = "light",
sunlight_propagates = true,
collision_box = {
type = "fixed",
fixed = {-1/4, -1/2, -1/4, 1/4, -1/8, 1/4},
},
selection_box = {
type = "fixed",
fixed = {-1/4, -1/2, -1/4, 1/4, 1/2, 1/4},
},
sounds = default.node_sound_defaults(),
groups = {oddly_breakable_by_hand = 1, snappy = 3, not_in_creative_inventory = 1},
flowerpot_plantname = nodename,
on_punch = flowerpot_on_punch,
})
end
-- empty flowerpot
minetest.register_node("flowerpot:empty", {
description = "Flowerpot",
drawtype = "mesh",
mesh = "flowerpot.obj",
tiles = {
{name = "flowerpot.png"},
{name = "doors_blank.png"},
},
paramtype = "light",
sunlight_propagates = true,
collision_box = {
type = "fixed",
fixed = {-1/4, -1/2, -1/4, 1/4, -1/8, 1/4},
},
selection_box = {
type = "fixed",
fixed = {-1/4, -1/2, -1/4, 1/4, 1/2, 1/4},
},
sounds = default.node_sound_defaults(),
groups = {oddly_breakable_by_hand = 3, cracky = 1},
on_rightclick = flowerpot_on_rightclick,
})
-- craft
minetest.register_craft({
output = "flowerpot:empty",
recipe = {
{"default:clay_brick", "", "default:clay_brick"},
{"", "default:clay_brick", ""},
}
})
-- default farming nodes
for _, node in pairs({
"default:sapling",
"default:aspen_sapling",
"default:pine_sapling",
"default:acacia_sapling",
"default:junglesapling",
"default:grass_1",
"default:grass_2",
"default:grass_3",
"default:grass_4",
"default:grass_5",
"default:dry_grass_1",
"default:dry_grass_2",
"default:dry_grass_3",
"default:dry_grass_4",
"default:dry_grass_5",
"default:junglegrass",
"default:dry_shrub",
"default:bush_stem",
"default:acacia_bush_stem",
"default:papyrus",
"flowers:rose",
"flowers:tulip",
"flowers:dandelion_yellow",
"flowers:geranium",
"flowers:viola",
"flowers:dandelion_white",
"flowers:mushroom_red",
"flowers:mushroom_brown",
}) do
flowerpot.register_node(node)
end

1
mod.conf Normal file
View File

@ -0,0 +1 @@
name = flowerpot

185
models/flowerpot.obj Normal file
View File

@ -0,0 +1,185 @@
# Blender v2.78 (sub 0) OBJ File: 'flowerpot.blend'
# www.blender.org
mtllib flowerpot.mtl
o Cube
v 0.187500 -0.437500 -0.187500
v 0.187500 -0.437500 0.187500
v -0.187500 -0.437500 0.187500
v -0.187500 -0.437500 -0.187500
v 0.187500 -0.125000 -0.187500
v 0.187500 -0.125000 0.187500
v -0.187500 -0.125000 0.187500
v -0.187500 -0.125000 -0.187500
v -0.125000 -0.125000 -0.125000
v 0.125000 -0.125000 0.125000
v 0.125000 -0.125000 -0.125000
v -0.125000 -0.125000 -0.125000
v 0.187500 -0.125000 0.125000
v 0.125000 -0.187500 -0.125000
v 0.125000 -0.187500 0.125000
v -0.187500 -0.125000 -0.125000
v 0.187500 -0.125000 -0.125000
v -0.125000 -0.187500 -0.125000
v -0.125000 -0.187500 0.125000
v -0.187500 -0.125000 0.125000
v 0.125000 -0.125000 0.125000
v -0.125000 -0.125000 -0.125000
v -0.125000 -0.125000 0.125000
v -0.125000 -0.125000 -0.125000
v 0.125000 -0.125000 -0.125000
v 0.125000 -0.125000 0.125000
v -0.125000 -0.125000 0.125000
v -0.125000 -0.125000 0.125000
v 0.125000 -0.125000 -0.125000
v 0.125000 -0.125000 0.125000
v 0.125000 -0.125000 -0.125000
v -0.125000 -0.125000 0.125000
v -0.224794 -0.187500 -0.217081
v -0.224794 0.437500 -0.217081
v 0.224794 -0.187500 0.217081
v 0.224794 0.437500 0.217081
v -0.217081 -0.187500 0.224794
v -0.217081 0.437500 0.224794
v 0.217081 -0.187500 -0.224794
v 0.217081 0.437500 -0.224794
v -0.125000 -0.500000 0.125000
v -0.125000 -0.500000 -0.125000
v 0.187500 -0.437500 0.125000
v 0.125000 -0.500000 -0.125000
v -0.187500 -0.437500 -0.125000
v 0.187500 -0.437500 -0.125000
v 0.125000 -0.500000 0.125000
v -0.187500 -0.437500 0.125000
v 0.125000 -0.437500 0.125000
v 0.125000 -0.437500 -0.125000
v -0.125000 -0.437500 -0.125000
v -0.125000 -0.437500 0.125000
vt 0.6250 0.5000
vt 0.6250 0.7500
vt 0.3750 0.7500
vt 0.3750 0.5000
vt 1.0000 0.5625
vt 1.0000 0.8750
vt 0.9375 0.8750
vt 0.6875 0.8750
vt 0.6250 0.8750
vt 0.6250 0.5625
vt 0.6875 0.5625
vt 0.9375 0.5625
vt 0.3750 0.9375
vt 0.0000 0.9375
vt 0.0000 0.8750
vt 0.3750 0.8750
vt 0.9375 0.9375
vt 0.6875 0.9375
vt 0.6875 0.8750
vt 0.9375 0.8750
vt 0.9375 0.9375
vt 0.3125 0.9375
vt 0.0625 0.9375
vt -0.0000 0.9375
vt -0.0000 0.8750
vt 0.3750 0.8750
vt 0.3750 0.9375
vt 0.0000 0.5625
vt 0.3750 0.5625
vt 0.3125 1.0000
vt 0.0625 1.0000
vt 0.9375 0.9375
vt 0.6875 0.9375
vt 0.6875 0.9375
vt 0.9375 0.9375
vt 1.0000 0.5625
vt 1.0000 0.8750
vt 0.6250 0.8750
vt 0.6250 0.5625
vt 0.6875 0.5625
vt 0.9375 0.5625
vt 0.3750 0.5625
vt 0.0000 0.5625
vt 0.0625 0.9375
vt 0.3125 0.9375
vt 0.3125 1.0000
vt 0.0625 1.0000
vt 0.9375 1.0000
vt 0.6875 1.0000
vt 0.9375 1.0000
vt 0.6875 1.0000
vt 0.0000 0.5000
vt 0.0625 0.5000
vt 0.3125 0.5000
vt 0.3750 0.5000
vt 0.3125 0.5000
vt 0.0625 0.5000
vt 0.0625 0.4375
vt 0.3125 0.4375
vt 0.3750 0.5000
vt 0.0000 0.5000
vt 0.6875 0.5000
vt 0.9375 0.5000
vt 0.6875 0.5000
vt 0.9375 0.5000
vt 0.3750 1.0000
vt 0.3750 0.7500
vt 0.6250 0.7500
vt 0.6250 1.0000
vt 0.6875 0.4375
vt 0.9375 0.4375
vt 0.0625 0.4375
vt 0.3125 0.4375
vt 0.6875 0.4375
vt 0.9375 0.4375
vt 0.9999 0.0001
vt 0.9999 0.9989
vt 0.0001 0.9989
vt 0.0001 0.0001
vt 0.9980 0.0020
vt 0.0020 0.0020
vt 0.0020 0.9983
vt 0.9980 0.9983
vn 0.0000 1.0000 0.0000
vn 1.0000 0.0000 0.0000
vn -0.0000 -0.0000 1.0000
vn -1.0000 -0.0000 -0.0000
vn 0.0000 0.0000 -1.0000
vn 0.0000 -1.0000 -0.0000
vn 0.6947 0.0000 -0.7193
vn 0.7193 -0.0000 0.6947
g Cube_Cube_pot
usemtl pot
s off
f 18/1/1 19/2/1 15/3/1 14/4/1
f 1/5/2 5/6/2 17/7/2 13/8/2 6/9/2 2/10/2 43/11/2 46/12/2
f 13/13/1 20/14/1 7/15/1 6/16/1
f 32/17/1 24/18/1 16/19/1 20/20/1 27/21/1
f 24/22/1 29/23/1 17/24/1 5/25/1 8/26/1 16/27/1
f 3/28/3 2/29/3 6/16/3 7/15/3
f 29/23/3 24/22/3 18/30/3 14/31/3
f 29/32/1 30/33/1 26/34/1 13/8/1 17/7/1 25/35/1
f 3/36/4 7/37/4 20/20/4 16/19/4 8/38/4 4/39/4 45/40/4 48/41/4
f 4/42/5 8/26/5 5/25/5 1/43/5
f 32/44/5 30/45/5 15/46/5 19/47/5
f 30/33/4 29/32/4 14/48/4 15/49/4
f 24/18/2 32/17/2 19/50/2 18/51/2
f 2/29/6 3/28/6 48/52/6 52/53/6 49/54/6 43/55/6
f 51/56/5 50/57/5 44/58/5 42/59/5
f 50/57/6 51/56/6 45/60/6 4/42/6 1/43/6 46/61/6
f 51/62/6 52/63/6 48/41/6 45/40/6
f 46/12/6 43/11/6 49/64/6 50/65/6
f 42/66/6 44/67/6 47/68/6 41/69/6
f 50/65/2 49/64/2 47/70/2 44/71/2
f 49/54/3 52/53/3 41/72/3 47/73/3
f 52/63/4 51/62/4 42/74/4 41/75/4
g Cube_Cube_plant
usemtl plant
f 33/76/7 34/77/7 36/78/7 35/79/7
f 37/80/8 39/81/8 40/82/8 38/83/8
l 28 23
l 22 9
l 11 31
l 19 28
l 14 11
l 18 22
l 10 21
l 24 12
l 15 10

34
readme.md Normal file
View File

@ -0,0 +1,34 @@
flowerpot
=========
This minetest mod adds a simple, single-node, non-entity flowerpot
that can contain `plantlike` drawtype nodes.
The player can place these pots as normal nodes, and then right-click
the pot with a plant or plantlike node, and the pot then will contain
a slightly smaller version of the plant. If punched, the plant that
was put in the pot will be returned to the puncher.
The concept works through the use of object materials. The empty
flowerpot node has the same model, but part of the mesh is transparent
and therefore not visible. If a plant is inserted, the transparent
textures are replaced with the texture of the plant node, and thus
it looks like the plant is inserted, while effectively the pot is a
single node without metadata.
There are no crafting recipes for each variant. The player can craft
pots and potentially use `/giveme` to give filled versions of the
flowerpot, but the creative inventory does not contain them as they
are easily filled already.
The model was made in blender from scratch by the author.
The texture of the flowerpot itself was created from the flowerpot
texture of the excellent Isabella II texture pack, which is Public
Domain. The texture has been reworked to allow for a more detailed
texturing of the flowerpot model.
The flowerpot mod has an API that can be used by other mods to create
new plant-flowerpot combinations. See api.md for usage information.

BIN
screenshot.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 81 KiB

BIN
textures/flowerpot.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 348 B