rework mod so that new shield color combos can be easily added

This commit is contained in:
FaceDeer 2017-02-25 18:18:51 -07:00
parent b861e41c8f
commit 2611633aa4
28 changed files with 203 additions and 43 deletions

16
default_shields.lua Normal file
View File

@ -0,0 +1,16 @@
minetest.register_alias("castle:shield", "castle_shields:shield_1")
minetest.register_alias("castle:shield_2", "castle_shields:shield_2")
minetest.register_alias("castle:shield_3", "castle_shields:shield_3")
-- internationalization boilerplate
local MP = minetest.get_modpath(minetest.get_current_modname())
local S, NS = dofile(MP.."/intllib.lua")
--The following colors are permitted:
-- "black", "blue", "brown", "cyan", "dark_green", "dark_grey", "green", "grey", "magenta", "orange", "pink", "red", "violet", "white", "yellow"
--The following patterns are permitted:
-- "slash", "chevron", "cross"
castle_shields.register_shield("shield_1", S("Mounted Shield"), "red", "blue", "slash")
castle_shields.register_shield("shield_2", S("Mounted Shield"), "cyan", "yellow", "chevron")
castle_shields.register_shield("shield_3", S("Mounted Shield"), "grey", "green", "cross")

View File

@ -1,47 +1,9 @@
minetest.register_alias("castle:shield", "castle_shields:shield")
minetest.register_alias("castle:shield", "castle_shields:shield_1")
minetest.register_alias("castle:shield_2", "castle_shields:shield_2")
minetest.register_alias("castle:shield_3", "castle_shields:shield_3")
-- internationalization boilerplate
castle_shields = {}
local MP = minetest.get_modpath(minetest.get_current_modname())
local S, NS = dofile(MP.."/intllib.lua")
local register_shield = function(name, tile_side, tile_front, dye_1, dye_2)
minetest.register_node("castle_shields:"..name, {
description = S("Mounted Shield"),
tiles = {tile_side, tile_side, tile_side, tile_side, "castle_shield_back.png", tile_front},
drawtype="nodebox",
paramtype2 = "facedir",
paramtype = "light",
groups={cracky=3},
sounds = default.node_sound_metal_defaults(),
node_box = {
type = "fixed",
fixed = {
{-0.500000,-0.125000,0.375000,0.500000,0.500000,0.500000},
{-0.437500,-0.312500,0.375000,0.425000,0.500000,0.500000},
{-0.312500,-0.437500,0.375000,0.312500,0.500000,0.500000},
{-0.187500,-0.500000,0.375000,0.187500,0.500000,0.500000},
},
},
selection_box = {
type = "fixed",
fixed = {
{-0.500000,-0.500000,0.375000,0.500000,0.500000,0.500000},
},
},
})
minetest.register_craft({
output = "castle_shields:"..name,
recipe = {
{"default:steel_ingot", "default:steel_ingot", "default:steel_ingot"},
{"default:steel_ingot", "default:steel_ingot", "default:steel_ingot"},
{dye_1, "default:steel_ingot", dye_2},
}
})
end
register_shield("shield", "castle_shield_side.png", "castle_shield_front.png", "dye:red", "dye:blue")
register_shield("shield_2", "castle_shield_side_2.png", "castle_shield_front_2.png", "dye:cyan", "dye:yellow")
register_shield("shield_3", "castle_shield_side_3.png", "castle_shield_front_3.png", "dye:grey", "dye:green")
dofile(MP.."/shield_functions.lua")
dofile(MP.."/default_shields.lua")

39
shield_functions.lua Normal file
View File

@ -0,0 +1,39 @@
castle_shields.register_shield = function(name, desc, background_color, foreground_color, mask)
local tile_side = "castle_shield_"..background_color..".png"
local tile_front = "castle_shield_"..background_color..".png^(castle_shield_"..foreground_color..".png^[mask:castle_shield_mask_"..mask..".png)"
minetest.register_node(minetest.get_current_modname()..":"..name, {
description = desc,
tiles = {tile_side, tile_side, tile_side, tile_side, "castle_shield_back.png", tile_front},
drawtype="nodebox",
paramtype2 = "facedir",
paramtype = "light",
groups={cracky=3},
sounds = default.node_sound_metal_defaults(),
node_box = {
type = "fixed",
fixed = {
{-0.500000,-0.125000,0.375000,0.500000,0.500000,0.500000},
{-0.437500,-0.312500,0.375000,0.425000,0.500000,0.500000},
{-0.312500,-0.437500,0.375000,0.312500,0.500000,0.500000},
{-0.187500,-0.500000,0.375000,0.187500,0.500000,0.500000},
},
},
selection_box = {
type = "fixed",
fixed = {
{-0.500000,-0.500000,0.375000,0.500000,0.500000,0.500000},
},
},
})
minetest.register_craft({
output = minetest.get_current_modname()..":"..name,
recipe = {
{"default:steel_ingot", "default:steel_ingot", "default:steel_ingot"},
{"default:steel_ingot", "default:steel_ingot", "default:steel_ingot"},
{"dye:"..background_color, "default:steel_ingot", "dye:"..foreground_color},
}
})
end

Binary file not shown.

After

Width:  |  Height:  |  Size: 275 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 379 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 424 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 328 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 371 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 319 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 520 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 701 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 536 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 388 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 355 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 420 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 223 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 153 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 183 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 441 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 338 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 426 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 94 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 91 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 101 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 364 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 339 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 398 B

143
textures/shield.svg Normal file
View File

@ -0,0 +1,143 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="16"
height="16"
viewBox="0 0 16 16"
id="svg2"
version="1.1"
inkscape:version="0.91 r13725"
sodipodi:docname="gradient.svg"
inkscape:export-filename="C:\Users\Bryan\Downloads\minetest-0.4.15-win64\mods\castle_shields\textures\rect4138.png"
inkscape:export-xdpi="90"
inkscape:export-ydpi="90">
<defs
id="defs4">
<linearGradient
inkscape:collect="always"
id="linearGradient4148">
<stop
style="stop-color:#fcf611;stop-opacity:1"
offset="0"
id="stop4150" />
<stop
style="stop-color:#ffc20b;stop-opacity:1"
offset="1"
id="stop4152" />
</linearGradient>
<radialGradient
inkscape:collect="always"
xlink:href="#linearGradient4148"
id="radialGradient4154"
cx="8"
cy="1043.8622"
fx="8"
fy="1043.8622"
r="3.5"
gradientTransform="matrix(3.1428571,-2.4687518e-6,2.4687459e-6,3.1428481,-17.145434,-2236.3381)"
gradientUnits="userSpaceOnUse" />
</defs>
<sodipodi:namedview
id="base"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="22.4"
inkscape:cx="12.024399"
inkscape:cy="9.317634"
inkscape:document-units="px"
inkscape:current-layer="layer4"
showgrid="true"
units="px"
showguides="true"
inkscape:guide-bbox="true"
inkscape:window-width="1680"
inkscape:window-height="987"
inkscape:window-x="2952"
inkscape:window-y="-8"
inkscape:window-maximized="1"
inkscape:snap-grids="true"
inkscape:snap-to-guides="true">
<inkscape:grid
type="xygrid"
id="grid4136" />
</sodipodi:namedview>
<metadata
id="metadata7">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<g
inkscape:label="Layer 1"
inkscape:groupmode="layer"
id="layer1"
transform="translate(0,-1036.3622)"
style="display:none">
<rect
style="fill:url(#radialGradient4154);fill-opacity:1;stroke:none;stroke-width:100;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="rect4138"
width="16"
height="16.000017"
x="0"
y="1036.3622"
inkscape:export-xdpi="90"
inkscape:export-ydpi="90" />
</g>
<g
inkscape:groupmode="layer"
id="layer2"
inkscape:label="sash"
style="display:none">
<path
style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:4;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="M 20,-4 -5,21"
id="path4163"
inkscape:connector-curvature="0"
inkscape:export-xdpi="90"
inkscape:export-ydpi="90" />
</g>
<g
inkscape:groupmode="layer"
id="layer3"
inkscape:label="chevron"
style="display:none">
<path
style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="M -4,-4 8,8 20,-4"
id="path4166"
inkscape:connector-curvature="0" />
</g>
<g
inkscape:groupmode="layer"
id="layer4"
inkscape:label="cross">
<path
style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;stroke-miterlimit:4;stroke-dasharray:none"
d="M 8,-4 8,20"
id="path4169"
inkscape:connector-curvature="0" />
<path
style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;stroke-miterlimit:4;stroke-dasharray:none"
d="M 20,6 -4,6"
id="path4171"
inkscape:connector-curvature="0" />
</g>
</svg>

After

Width:  |  Height:  |  Size: 4.5 KiB