2018-12-19 05:14:40 -08:00
|
|
|
minetest.register_craft({
|
|
|
|
output = 'tombs:machine',
|
|
|
|
recipe = {
|
|
|
|
{'default:stone', 'default:stone', 'default:stone'},
|
|
|
|
{'default:steel_ingot', 'default:diamond', 'default:steel_ingot'},
|
|
|
|
{'default:stone', 'default:stone', 'default:stone'}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
2018-11-03 20:44:07 -07:00
|
|
|
minetest.register_node('tombs:machine', {
|
|
|
|
description = 'Gravestone Engraver',
|
|
|
|
tiles = {
|
|
|
|
'tombs_machine_side.png',
|
|
|
|
'tombs_machine_side.png',
|
|
|
|
'tombs_machine_side.png',
|
|
|
|
'tombs_machine_side.png',
|
|
|
|
'tombs_machine_side.png',
|
|
|
|
'tombs_machine_front.png',
|
|
|
|
},
|
|
|
|
groups = {oddly_breakable_by_hand=3},
|
|
|
|
paramtype2 = 'facedir',
|
|
|
|
on_construct = function(pos)
|
|
|
|
local meta = minetest.get_meta(pos)
|
|
|
|
meta:set_string('infotext', 'Gravestone Creator')
|
2018-12-01 14:40:43 -08:00
|
|
|
meta:set_string('formspec', machine_formspec_centered)
|
2018-12-19 05:14:40 -08:00
|
|
|
meta:set_string('var', 0)
|
2018-11-03 20:44:07 -07:00
|
|
|
local inv = meta:get_inventory()
|
|
|
|
inv:set_size('tool', 1)
|
|
|
|
inv:set_size('input', 1)
|
2018-12-01 14:40:43 -08:00
|
|
|
inv:set_size('output', 15)
|
2018-11-03 20:44:07 -07:00
|
|
|
end,
|
|
|
|
on_receive_fields = function(pos, formname, fields, sender)
|
|
|
|
local meta = minetest.get_meta(pos)
|
|
|
|
local inv = meta:get_inventory()
|
2018-12-01 14:40:43 -08:00
|
|
|
local input_stack = inv:get_stack('input', 1)
|
|
|
|
local input = input_stack:get_name()
|
|
|
|
if fields ['offset'] then
|
|
|
|
meta:set_string('formspec', machine_formspec_offset)
|
2018-12-03 07:49:04 -08:00
|
|
|
meta:set_string('var', 1)
|
2018-12-12 07:20:27 -08:00
|
|
|
tombs.populate_output(pos)
|
2018-12-01 14:40:43 -08:00
|
|
|
elseif fields ['centered'] then
|
|
|
|
meta:set_string('formspec', machine_formspec_centered)
|
2018-12-03 07:49:04 -08:00
|
|
|
meta:set_string('var', 0)
|
2018-12-12 07:20:27 -08:00
|
|
|
tombs.populate_output(pos)
|
2018-11-03 20:44:07 -07:00
|
|
|
end
|
|
|
|
end,
|
|
|
|
can_dig = function(pos)
|
|
|
|
local meta = minetest.get_meta(pos)
|
|
|
|
local inv = meta:get_inventory()
|
|
|
|
if inv:is_empty('tool') and
|
|
|
|
inv:is_empty('input') and
|
|
|
|
inv:is_empty('output') then
|
|
|
|
return true
|
|
|
|
else
|
|
|
|
return false
|
|
|
|
end
|
|
|
|
end,
|
2018-12-01 14:40:43 -08:00
|
|
|
allow_metadata_inventory_put = function(pos, listname, index, stack, player)
|
|
|
|
if listname == 'input' then
|
|
|
|
local input = stack:get_name()
|
|
|
|
if not tombs.nodes[input] then
|
|
|
|
return 0
|
|
|
|
else
|
|
|
|
return 99
|
|
|
|
end
|
|
|
|
end
|
|
|
|
if listname == 'tool' then
|
2019-01-25 19:37:02 -08:00
|
|
|
if stack:get_name() == 'bones:bones' then
|
2018-12-01 14:40:43 -08:00
|
|
|
return 99
|
2019-01-25 19:37:02 -08:00
|
|
|
elseif stack:get_name() == 'tombs:chisel' then
|
|
|
|
return 1
|
|
|
|
elseif stack:get_name() == 'mychisel:chisel' then
|
|
|
|
return 1
|
2018-12-01 14:40:43 -08:00
|
|
|
else
|
|
|
|
return 0
|
|
|
|
end
|
|
|
|
end
|
|
|
|
if listname == 'output' then
|
|
|
|
return 0
|
|
|
|
end
|
|
|
|
end,
|
2018-12-19 05:14:40 -08:00
|
|
|
on_metadata_inventory_put = function(pos)
|
|
|
|
tombs.populate_output(pos)
|
2018-12-01 14:40:43 -08:00
|
|
|
end,
|
|
|
|
on_metadata_inventory_take = function(pos, listname, index, stack, player)
|
|
|
|
local meta = minetest.get_meta(pos)
|
|
|
|
local inv = meta:get_inventory()
|
2018-12-03 07:49:04 -08:00
|
|
|
local input_stack = inv:get_stack('input', 1)
|
2018-12-12 07:20:27 -08:00
|
|
|
local tool_stack = inv:get_stack('tool', 1)
|
2018-12-03 07:49:04 -08:00
|
|
|
local input = input_stack:get_name()
|
|
|
|
local var = meta:get_string('var')
|
2018-12-01 14:40:43 -08:00
|
|
|
if listname == 'input' then
|
|
|
|
inv:set_list('output', {})
|
2018-12-12 07:20:27 -08:00
|
|
|
elseif listname == 'tool' then
|
|
|
|
inv:set_list('output', {})
|
2018-12-01 14:40:43 -08:00
|
|
|
elseif listname == 'output' then
|
2018-12-03 07:49:04 -08:00
|
|
|
input_stack:take_item(1)
|
2019-01-25 19:37:02 -08:00
|
|
|
if tool_stack:get_name() == 'bones:bones' then
|
|
|
|
tool_stack:take_item(1)
|
|
|
|
elseif tool_stack:get_name() == 'tombs:chisel' then
|
|
|
|
tool_stack:add_wear(65535 / 48)
|
|
|
|
elseif tool_stack:get_name() == 'mychisel:chisel' then
|
|
|
|
tool_stack:add_wear(65535 / 48)
|
|
|
|
end
|
2018-12-12 07:20:27 -08:00
|
|
|
inv:set_stack('tool',1,tool_stack)
|
2018-12-03 07:49:04 -08:00
|
|
|
inv:set_stack('input',1,input_stack)
|
2018-12-12 07:20:27 -08:00
|
|
|
if inv:is_empty('input') then
|
|
|
|
inv:set_list('output', {})
|
|
|
|
elseif inv:is_empty('tool') then
|
|
|
|
inv:set_list('output', {})
|
|
|
|
else
|
|
|
|
tombs.populate_output(pos)
|
|
|
|
end
|
2018-12-01 14:40:43 -08:00
|
|
|
end
|
|
|
|
end,
|
2018-11-03 20:44:07 -07:00
|
|
|
})
|
2018-12-12 07:20:27 -08:00
|
|
|
|
|
|
|
function tombs.populate_output(pos)
|
|
|
|
local meta = minetest.get_meta(pos)
|
|
|
|
local inv = meta:get_inventory()
|
|
|
|
local input_stack = inv:get_stack('input', 1)
|
|
|
|
local tool_stack = inv:get_stack('tool', 1)
|
|
|
|
local input = input_stack:get_name()
|
|
|
|
local var = meta:get_string('var')
|
2019-01-25 19:37:02 -08:00
|
|
|
if tombs.nodes[input] then
|
|
|
|
if tool_stack:get_name() == 'bones:bones' or tool_stack:get_name() == 'tombs:chisel'
|
|
|
|
or tool_stack:get_name() == 'mychisel:chisel' then
|
|
|
|
inv:set_list('output', tombs.crafting(input, var))
|
|
|
|
end
|
2018-12-19 05:14:40 -08:00
|
|
|
else
|
|
|
|
inv:set_list('output', {})
|
2018-12-12 07:20:27 -08:00
|
|
|
end
|
|
|
|
end
|