support for default and wool.

master
NathanSalapat 2018-12-12 09:20:27 -06:00
parent 8ca26a21f8
commit 826412411d
9 changed files with 120 additions and 38 deletions

3
api.txt Normal file
View File

@ -0,0 +1,3 @@
You can easily add custom materials for the tombstones by simply calling
tombs.register_stones('modname:nodename', 'nodename', 'description', 'texture')
DO NOT include the extension for the texture or you will get an error.

View File

@ -1,9 +1,19 @@
colbox_0_0 ={
colbox_0_0 ={ --Centered Rectangle
type = 'fixed',
fixed = {{-.375, -.5, -.125, .375, .4375, .125}}
}
colbox_0_1 ={
colbox_0_1 ={ --Offset Rectangle
type = 'fixed',
fixed = {{-.375, -.5, .125, .375, .4375, .375}}
}
colbox_1_0 ={ --Centered Cross
type = 'fixed',
fixed = {{-.375, -.5, -.125, .375, .475, .125}}
}
colbox_1_1 ={ --Offset Cross
type = 'fixed',
fixed = {{-.375, -.5, .125, .375, .475, .375}}
}

22
default.lua Normal file
View File

@ -0,0 +1,22 @@
tombs.register_stones('default:acacia_wood', 'acacia', 'Acacia', 'default_acacia_wood')
tombs.register_stones('default:aspen_wood', 'aspen', 'Aspen', 'default_aspen_wood')
tombs.register_stones('default:bronze_ingot', 'bronze', 'Bronze', 'default_bronze_block')
tombs.register_stones('default:clay', 'clay', 'Clay', 'default_clay')
tombs.register_stones('default:coalblock', 'coal', 'Coal', 'default_coal_block')
tombs.register_stones('default:cobble', 'cobble', 'Cobblestone', 'default_cobble')
tombs.register_stones('default:copper_ingot', 'copper', 'Copper', 'default_copper_block')
tombs.register_stones('default:coral_skeleton', 'coral', 'Coral', 'default_coral_skeleton')
tombs.register_stones('default:desert_sandstone', 'desert_sandstone', 'Desert Sandstone', 'default_desert_sandstone')
tombs.register_stones('default:desert_stone', 'desert_stone', 'Desert Stone', 'default_desert_stone')
tombs.register_stones('default:diamond', 'diamond', 'Diamond', 'default_diamond_block')
tombs.register_stones('default:gold_ingot', 'gold', 'Gold', 'default_gold_block')
tombs.register_stones('default:junglewood', 'junglewood', 'Junglewood', 'default_junglewood')
tombs.register_stones('default:mossycobble', 'mossycobble', 'Mossy Cobblestone', 'default_mossycobble')
tombs.register_stones('default:obsidian', 'obsidian', 'Obsidian', 'default_obsidian')
tombs.register_stones('default:pine_wood', 'pine', 'Pine', 'default_pine_wood')
tombs.register_stones('default:sandstone', 'sandstone', 'Sandstone', 'default_sandstone')
tombs.register_stones('default:silver_sandstone', 'silver_sandstone', 'Silver Sandstone', 'default_silver_sandstone')
tombs.register_stones('default:steel_ingot', 'steel', 'Steel', 'default_steel_block')
tombs.register_stones('default:stone', 'stone', 'Stone', 'default_stone')
tombs.register_stones('default:tin_ingot', 'tin', 'Tin', 'default_tin_block')
tombs.register_stones('default:wood', 'wood', 'Wood', 'default_wood')

View File

@ -1,2 +1,3 @@
default
bones?
bones
wool?

View File

@ -1,7 +1,7 @@
machine_formspec_centered =
'size[8,7.5]'..
'list[context;tool;0,0;1,1]'..
'label[1,0;Tool/Bones]'..
'label[1,0;Bones]'..
'list[context;input;0,1;1,1]'..
'label[1,1;Material]'..
'label[0,2;Click to change to offset versions.]'..
@ -12,7 +12,7 @@ machine_formspec_centered =
machine_formspec_offset =
'size[8,7.5]'..
'list[context;tool;0,0;1,1]'..
'label[1,0;Tool/Bones]'..
'label[1,0;Bones]'..
'list[context;input;0,1;1,1]'..
'label[1,1;Material]'..
'label[0,2;Click to change to centered versions.]'..

View File

@ -1,22 +1,24 @@
function tombs.register_stones(recipe, name, desc, textures)
shapes = { --mesh identifier, shape
{'_0', 'Rectangle'},
{'_1', 'Cross'}
shapes = { --mesh identifier, shape, col
{'_0', 'Rectangle', colbox_0_0, colbox_0_1},
{'_1', 'Cross', colbox_1_0, colbox_1_1}
}
for i in ipairs (shapes) do
local mesh = shapes[i][1]
local shape = shapes[i][2]
local centered_col = shapes[i][3]
local offset_col = shapes[i][4]
minetest.register_node('tombs:'..name..mesh..'_0', {
description = desc..' Grave Marker('..shape..')',
minetest.register_node('tombs:'..string.lower(name)..mesh..'_0', {
description = desc..' Grave Marker ('..shape..')',
drawtype = 'mesh',
mesh = 'tombs'..mesh..'_0.obj',
tiles = {textures..'.png'},
paramtype = 'light',
paramtype2 = 'facedir',
selection_box = colbox_0_0,
collision_box = colbox_0_0,
selection_box = centered_col,
collision_box = centered_col,
groups = {cracky=2, oddly_breakable_by_hand=1,},
on_construct = function(pos)
local meta = minetest.get_meta(pos)
@ -29,15 +31,15 @@ for i in ipairs (shapes) do
end,
})
minetest.register_node('tombs:'..name..mesh..'_1', {
description = 'Offset '..desc..' Grave Marker('..shape..')',
minetest.register_node('tombs:'..string.lower(name)..mesh..'_1', {
description = 'Offset '..desc..' Grave Marker ('..shape..')',
drawtype = 'mesh',
mesh = 'tombs'..mesh..'_1.obj',
tiles = {textures..'.png'},
paramtype = 'light',
paramtype2 = 'facedir',
selection_box = colbox_0_1,
collision_box = colbox_0_1,
selection_box = offset_col,
collision_box = offset_col,
groups = {cracky=2, oddly_breakable_by_hand=1,},
on_construct = function(pos)
local meta = minetest.get_meta(pos)
@ -53,25 +55,12 @@ for i in ipairs (shapes) do
end
tombs.nodes[recipe] = true
tombs.recipes[recipe] = string.lower(name)
end
tombs.register_stones('default:cobble', 'cobble', 'Cobble', 'default_cobble') --recipe, name, desc, texture
tombs.register_stones('default:stone', 'stone', 'Stone', 'default_stone')
tombs.register_stones('default:gold_ingot', 'gold', 'Gold', 'default_gold_block')
tombs.register_stones('default:acacia_wood', 'acacia', 'Acacia', 'default_acacia_wood')
function tombs.crafting(input, var)
local mod, name = input:match("([^:]+):([^:]+)")
if input == '' then
output = {}
return output
elseif string.find(name, '_') then
local name, junk = name:match('([^_]+)_([^_]+)')
print ('this is name: '..input)
output = {'tombs:'..name..'_0_'..var, 'tombs:'..name..'_1_'..var}
return output
end
local name = tombs.recipes[input]
output = {'tombs:'..name..'_0_'..var, 'tombs:'..name..'_1_'..var}
return output
end

View File

@ -6,3 +6,12 @@ dofile(minetest.get_modpath('tombs')..'/machine.lua')
dofile(minetest.get_modpath('tombs')..'/collision_boxes.lua')
dofile(minetest.get_modpath('tombs')..'/gravestones.lua')
dofile(minetest.get_modpath('tombs')..'/formspec.lua')
--support for other mods
if minetest.get_modpath('default') then
dofile(minetest.get_modpath('tombs')..'/default.lua')
end
if minetest.get_modpath('wool') then
dofile(minetest.get_modpath('tombs')..'/wool.lua')
end

View File

@ -1,5 +1,3 @@
local center = '0'
minetest.register_node('tombs:machine', {
description = 'Gravestone Engraver',
tiles = {
@ -29,11 +27,13 @@ minetest.register_node('tombs:machine', {
if fields ['offset'] then
meta:set_string('formspec', machine_formspec_offset)
meta:set_string('var', 1)
inv:set_list('output', tombs.crafting(input, 1))
-- inv:set_list('output', tombs.crafting(input, 1))
tombs.populate_output(pos)
elseif fields ['centered'] then
meta:set_string('formspec', machine_formspec_centered)
meta:set_string('var', 0)
inv:set_list('output', tombs.crafting(input, 0))
-- inv:set_list('output', tombs.crafting(input, 0))
tombs.populate_output(pos)
end
end,
can_dig = function(pos)
@ -71,8 +71,11 @@ minetest.register_node('tombs:machine', {
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()
if listname == 'input' then
if listname == 'input' and tool_stack:get_name() == ('bones:bones') then
inv:set_list('output', tombs.crafting(input, 0))
elseif listname == 'tool' and tombs.nodes[input] then
inv:set_list('output', tombs.crafting(input, 0))
end
end,
@ -80,14 +83,37 @@ minetest.register_node('tombs:machine', {
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')
if listname == 'input' then
inv:set_list('output', {})
elseif listname == 'tool' then
inv:set_list('output', {})
elseif listname == 'output' then
input_stack:take_item(1)
tool_stack:take_item(1)
inv:set_stack('tool',1,tool_stack)
inv:set_stack('input',1,input_stack)
inv:set_list('output', tombs.crafting(input, var))
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
end
end,
})
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')
if tombs.nodes[input] and tool_stack:get_name() == ('bones:bones') then
inv:set_list('output', tombs.crafting(input, var))
end
end

22
wool.lua Normal file
View File

@ -0,0 +1,22 @@
local dyes = {
{"white", "White"},
{"grey", "Grey"},
{"black", "Black"},
{"red", "Red"},
{"yellow", "Yellow"},
{"green", "Green"},
{"cyan", "Cyan"},
{"blue", "Blue"},
{"magenta", "Magenta"},
{"orange", "Orange"},
{"violet", "Violet"},
{"brown", "Brown"},
{"pink", "Pink"},
{"dark_grey", "Dark Grey"},
{"dark_green", "Dark Green"},
}
for i = 1, #dyes do
local name, desc = unpack(dyes[i])
tombs.register_stones('wool:'..name, name, desc, 'wool_'..name)
end