2019-02-20 00:40:55 -05:00
|
|
|
-- LUALOCALS < ---------------------------------------------------------
|
|
|
|
local minetest, nodecore
|
2019-02-28 23:16:07 -05:00
|
|
|
= minetest, nodecore
|
2019-02-20 00:40:55 -05:00
|
|
|
-- LUALOCALS > ---------------------------------------------------------
|
|
|
|
|
|
|
|
local modname = minetest.get_current_modname()
|
|
|
|
|
2019-02-23 20:35:22 -05:00
|
|
|
local side = "nc_tree_tree_side.png"
|
|
|
|
local top = side .. "^(" .. modname .. "_plank.png^[mask:"
|
|
|
|
.. modname .. "_shelf.png)"
|
|
|
|
|
2019-09-21 12:12:52 -04:00
|
|
|
local function doplace(stack, clicker, pointed_thing, ...)
|
|
|
|
local function helper(left, ok, ...)
|
|
|
|
if ok then nodecore.node_sound(pointed_thing.above, "place") end
|
|
|
|
return left, ok, ...
|
|
|
|
end
|
|
|
|
return helper(minetest.item_place_node(stack, clicker, pointed_thing, ...))
|
|
|
|
end
|
|
|
|
|
2019-02-20 00:40:55 -05:00
|
|
|
minetest.register_node(modname .. ":shelf", {
|
|
|
|
description = "Wooden Shelf",
|
|
|
|
drawtype = "nodebox",
|
|
|
|
node_box = nodecore.fixedbox(
|
|
|
|
{-0.5, -0.5, -0.5, 0.5, -7/16, 0.5},
|
|
|
|
{-0.5, 7/16, -0.5, 0.5, 0.5, 0.5},
|
|
|
|
{-0.5, -7/16, -0.5, -7/16, 7/16, -7/16},
|
|
|
|
{-0.5, -7/16, 7/16, -7/16, 7/16, 0.5},
|
|
|
|
{7/16, -7/16, -0.5, 0.5, 7/16, -7/16},
|
|
|
|
{7/16, -7/16, 7/16, 0.5, 7/16, 0.5}
|
|
|
|
),
|
2019-03-30 21:23:02 -04:00
|
|
|
selection_box = nodecore.fixedbox(),
|
|
|
|
collision_box = nodecore.fixedbox(),
|
2019-12-01 11:08:12 -05:00
|
|
|
tiles = {top, top, side},
|
2019-02-20 00:40:55 -05:00
|
|
|
groups = {
|
|
|
|
choppy = 1,
|
2019-02-23 10:00:31 -05:00
|
|
|
visinv = 1,
|
|
|
|
flammable = 2,
|
|
|
|
fire_fuel = 3,
|
2019-03-02 21:41:25 -05:00
|
|
|
container = 1,
|
2019-02-28 00:02:00 -05:00
|
|
|
totable = 1
|
2019-02-20 00:40:55 -05:00
|
|
|
},
|
|
|
|
paramtype = "light",
|
2019-03-13 23:51:59 -04:00
|
|
|
sounds = nodecore.sounds("nc_tree_woody"),
|
2019-02-20 00:40:55 -05:00
|
|
|
on_construct = function(pos)
|
|
|
|
local inv = minetest.get_meta(pos):get_inventory()
|
|
|
|
inv:set_size("solo", 1)
|
|
|
|
nodecore.visinv_update_ents(pos)
|
|
|
|
end,
|
2019-08-31 09:26:53 -04:00
|
|
|
on_rightclick = function(pos, _, clicker, stack, pointed_thing)
|
2019-02-24 21:54:33 -05:00
|
|
|
if not nodecore.interact(clicker) then return end
|
2019-09-21 09:50:26 -04:00
|
|
|
if pointed_thing.above.y ~= pointed_thing.under.y then
|
2019-09-21 12:12:52 -04:00
|
|
|
return doplace(stack, clicker, pointed_thing)
|
2019-09-21 09:50:26 -04:00
|
|
|
end
|
2019-02-20 00:40:55 -05:00
|
|
|
if not stack or stack:is_empty() then return end
|
2019-03-13 23:51:59 -04:00
|
|
|
local def = minetest.registered_items[stack:get_name()] or {}
|
2019-09-21 09:50:26 -04:00
|
|
|
if def.groups and def.groups.container then
|
2019-09-21 12:12:52 -04:00
|
|
|
return doplace(stack, clicker, pointed_thing)
|
2019-02-23 10:33:17 -05:00
|
|
|
end
|
2019-02-23 10:21:27 -05:00
|
|
|
return nodecore.stack_add(pos, stack)
|
2019-02-20 00:40:55 -05:00
|
|
|
end,
|
2019-03-06 13:50:54 -05:00
|
|
|
on_punch = function(pos, node, puncher, pointed_thing, ...)
|
|
|
|
minetest.node_punch(pos, node, puncher, pointed_thing, ...)
|
2019-02-24 21:54:33 -05:00
|
|
|
if not nodecore.interact(puncher) then return end
|
2019-02-23 20:06:14 -05:00
|
|
|
if pointed_thing.above.y ~= pointed_thing.under.y then return end
|
2019-02-23 10:21:27 -05:00
|
|
|
return nodecore.stack_giveto(pos, puncher)
|
2019-02-20 00:40:55 -05:00
|
|
|
end,
|
|
|
|
on_dig = function(pos, node, digger, ...)
|
2019-02-23 10:21:27 -05:00
|
|
|
if nodecore.stack_giveto(pos, digger) then
|
2019-02-20 00:40:55 -05:00
|
|
|
return minetest.node_dig(pos, node, digger, ...)
|
|
|
|
end
|
2019-03-02 21:41:25 -05:00
|
|
|
end,
|
2019-09-07 11:28:51 -04:00
|
|
|
on_ignite = function(pos)
|
|
|
|
return nodecore.stack_get(pos)
|
|
|
|
end,
|
2019-08-31 09:26:53 -04:00
|
|
|
stack_allow = function(_, _, stack)
|
2019-03-13 23:51:59 -04:00
|
|
|
local def = minetest.registered_items[stack:get_name()] or {}
|
|
|
|
if def.groups and def.groups.container then return false end
|
2019-02-20 00:40:55 -05:00
|
|
|
end
|
|
|
|
})
|
|
|
|
|
|
|
|
nodecore.register_craft({
|
2019-02-21 14:59:41 -05:00
|
|
|
label = "assemble wood shelf",
|
2019-02-28 23:15:26 -05:00
|
|
|
norotate = true,
|
2019-02-20 00:40:55 -05:00
|
|
|
nodes = {
|
|
|
|
{match = modname .. ":plank", replace = "air"},
|
2019-02-28 23:15:26 -05:00
|
|
|
{x = -1, z = -1, match = modname .. ":frame", replace = modname .. ":shelf"},
|
|
|
|
{x = 1, z = -1, match = modname .. ":frame", replace = modname .. ":shelf"},
|
|
|
|
{x = -1, z = 1, match = modname .. ":frame", replace = modname .. ":shelf"},
|
|
|
|
{x = 1, z = 1, match = modname .. ":frame", replace = modname .. ":shelf"},
|
2019-02-20 00:40:55 -05:00
|
|
|
}
|
|
|
|
})
|
2019-02-21 14:37:22 -05:00
|
|
|
|
|
|
|
nodecore.register_craft({
|
2019-02-21 14:59:41 -05:00
|
|
|
label = "assemble wood shelf",
|
2019-02-28 23:15:26 -05:00
|
|
|
norotate = true,
|
2019-02-21 14:37:22 -05:00
|
|
|
nodes = {
|
|
|
|
{match = modname .. ":plank", replace = "air"},
|
2019-02-28 23:15:26 -05:00
|
|
|
{x = 0, z = -1, match = modname .. ":frame", replace = modname .. ":shelf"},
|
|
|
|
{x = 0, z = 1, match = modname .. ":frame", replace = modname .. ":shelf"},
|
|
|
|
{x = -1, z = 0, match = modname .. ":frame", replace = modname .. ":shelf"},
|
|
|
|
{x = 1, z = 0, match = modname .. ":frame", replace = modname .. ":shelf"},
|
2019-02-21 14:37:22 -05:00
|
|
|
}
|
|
|
|
})
|