kingdoms_game/mods/alchemy/beakers.lua

104 lines
2.5 KiB
Lua
Raw Normal View History

2018-12-20 20:40:01 +00:00
local box = {
{-0.099, -0.483, -0.099, 0.099, -0.291, 0.099},
{-0.053, -0.291, -0.053, 0.053, -0.206, 0.053},
{-0.071, -0.206, -0.071, 0.071, -0.186, 0.071},
}
-- Empty beaker
minetest.register_node("alchemy:beaker_empty", {
description = "Empty Beaker",
drawtype = "mesh",
2018-12-23 17:36:23 -05:00
groups = {vessel = 1}, -- Unbreakable but picked up on punch - no particles
2018-12-20 20:40:01 +00:00
paramtype = "light",
sunlight_propagates = true,
2018-12-22 23:04:48 -05:00
inventory_image = "beaker_empty.png",
2018-12-20 20:40:01 +00:00
tiles = {
"beaker.png"
},
node_box = {
type = "fixed",
fixed = box,
},
selection_box = {
type = "fixed",
fixed = box,
},
mesh = "beaker_empty.x",
on_punch = function(pos, node, puncher)
local pName = puncher:get_player_name()
-- Check protection
if minetest.is_protected(pos, pName) then
minetest.record_protection_violation(pos, pName)
return
end
-- Pick up node
minetest.node_dig(pos, node, puncher)
end
})
-- Full beaker(s)
local function register_beaker(name, description, texture)
local bname = "alchemy:beaker_" .. name
local desc = "Beaker of " .. description
2018-12-20 20:40:01 +00:00
minetest.register_node(bname, {
description = desc,
2018-12-20 20:40:01 +00:00
drawtype = "mesh",
2018-12-23 17:36:23 -05:00
groups = {vessel = 1}, -- Unbreakable but picked up on punch - no particles
2018-12-20 20:40:01 +00:00
paramtype = "light",
stack_max = 1,
sunlight_propagates = true,
inventory_image = texture .. "^beaker_mask.png^[makealpha:0,0,0^beaker_empty.png",
2018-12-20 20:40:01 +00:00
tiles = {
"beaker.png",
texture
},
node_box = {
type = "fixed",
fixed = box,
},
selection_box = {
type = "fixed",
fixed = box,
},
mesh = "beaker.x",
on_construct = function(pos)
local meta = minetest.get_meta(pos)
meta:set_string("infotext", desc)
end,
2018-12-20 20:40:01 +00:00
on_punch = function(pos, node, puncher)
local pName = puncher:get_player_name()
-- Check protection
if minetest.is_protected(pos, pName) then
minetest.record_protection_violation(pos, pName)
return
end
-- Pick up node
minetest.node_dig(pos, node, puncher)
end,
on_drop = function(itemstack, dropper, pos)
local effect = alchemy.effects[itemstack:get_name()]
if effect then
effect(dropper, pos)
end
itemstack:take_item()
return itemstack
end
})
end
alchemy.register_beaker = register_beaker