summaryrefslogtreecommitdiff
path: root/init.lua
diff options
context:
space:
mode:
Diffstat (limited to 'init.lua')
-rw-r--r--init.lua102
1 files changed, 44 insertions, 58 deletions
diff --git a/init.lua b/init.lua
index e9e195e..aa71d44 100644
--- a/init.lua
+++ b/init.lua
@@ -1,3 +1,7 @@
+-- This mod provides a selection of window frames from different materials
+-- They are used by "snapping" a frame to a glass pane, and the frame is positioned
+-- propely due to model having an offset
+
local materials = {
["wood"] = "default",
["junglewood"] = "default",
@@ -19,35 +23,58 @@ local frametypes = {
{
name = "Simple window frame",
node = "window_frame_simple",
- model = "si_frame_simple.obj"
+ model = "si_frame_simple.obj",
+ howto = {
+ {"default:stick", "default:stick", "default:stick"},
+ {"default:stick", "%MATERIAL%", "default:stick"},
+ {"default:stick", "default:stick", "default:stick"}
+ }
},
{
name = "Quartered window frame",
node = "window_frame_quartered",
- model = "si_frame_quartered.obj"
+ model = "si_frame_quartered.obj",
+ howto = {
+ {"", "default:stick", ""},
+ {"default:stick", "%MATERIAL%", "default:stick"},
+ {"", "default:stick", ""}
+ }
},
{
name = "Quartered (diagonal) window frame",
node = "window_frame_quartered_diagonal",
- model = "si_frame_quartered_diagonal.obj"
+ model = "si_frame_quartered_diagonal.obj",
+ howto = {
+ {"default:stick", "", "default:stick"},
+ {"", "%MATERIAL%", ""},
+ {"default:stick", "", "default:stick"}
+ }
},
}
for material, modname in pairs(materials) do
+
if minetest.get_modpath(modname) then
+
local nodedef = minetest.registered_nodes[modname .. ":" .. material]
+
if nodedef then
local texture = nodedef.tiles[1]
if texture then
+
for _,f in ipairs(frametypes) do
- minetest.register_node ("si_frames:" .. f.node .. "_" .. material, {
- description = f.name,
+ local nodename = "si_frames:" .. f.node .. "_" .. material
+
+ minetest.register_node (nodename, {
+ description = f.name .. " (" .. material .. ")",
drawtype = "mesh",
mesh = f.model,
tiles = {texture},
+ inventory_image = texture .. "^" .. f.node .. ".png",
+ wield_image = texture .. "^" .. f.node .. ".png",
paramtype = "light",
paramtype2 = "facedir",
is_ground_content = false,
@@ -60,62 +87,21 @@ for material, modname in pairs(materials) do
},
collisionbox = {{-0.4, -0.45, 0.4, 0.4, 0.4, 0.5}},
})
-
+ if f.howto[2][2] == "%MATERIAL%" then
+ f.howto[2][2] = modname .. ":" .. material
+ minetest.register_craft({
+ output = nodename,
+ recipe = f.howto
+ })
+ f.howto[2][2] = "%MATERIAL%"
+ else
+ minetest.log("error", "Wrong recipe template for " .. nodename)
+ minetest.log("error", "--> " .. f.howto[2][2])
+ end
+
end
end
end
end
end
-
---[[
-
-minetest.register_node ("si_frames:window_frame_simple", {
- description = "Simple window frame",
- drawtype = "mesh",
- mesh = "si_frame_simple.obj",
- tiles = {"maple_wood.png"},
- paramtype2 = "facedir",
- is_ground_content = false,
- groups = {choppy=1, snappy=1, oddly_breakable_by_hand=1 },
- sounds = default.node_sound_stone_defaults(),
- walkable = false,
- selection_box = { type = "fixed",
- fixed = {{-0.4, -0.45, 0.4, 0.4, 0.4, 0.5}}
- },
- collisionbox = {{-0.4, -0.45, 0.4, 0.4, 0.4, 0.5}},
-})
-
-minetest.register_node ("si_frames:window_frame_quartered", {
- description = "Quartered window frame",
- drawtype = "mesh",
- mesh = "si_frame_quartered.obj",
- tiles = {"maple_wood.png"},
- paramtype2 = "facedir",
- is_ground_content = false,
- groups = {choppy=1, snappy=1, oddly_breakable_by_hand=1 },
- sounds = default.node_sound_stone_defaults(),
- walkable = false,
- selection_box = { type = "fixed",
- fixed = {{-0.4, -0.45, 0.4, 0.4, 0.4, 0.5}}
- },
- collisionbox = {{-0.4, -0.45, 0.4, 0.4, 0.4, 0.5}},
-})
-
-minetest.register_node ("si_frames:window_frame_quartered_diagonal", {
- description = "Quartered (diagonal) window frame",
- drawtype = "mesh",
- mesh = "si_frame_quartered_diagonal.obj",
- tiles = {"maple_wood.png"},
- paramtype2 = "facedir",
- is_ground_content = false,
- groups = {choppy=1, snappy=1, oddly_breakable_by_hand=1 },
- sounds = default.node_sound_stone_defaults(),
- walkable = false,
- selection_box = { type = "fixed",
- fixed = {{-0.4, -0.45, 0.4, 0.4, 0.4, 0.5}}
- },
- collisionbox = {{-0.4, -0.45, 0.4, 0.4, 0.4, 0.5}},
-})
-
-]]--