Public API for easy registration of new cats

This commit is contained in:
Aaron Suen 2023-06-04 20:35:38 -04:00
parent 77a852c73d
commit e711440984

View File

@ -88,20 +88,22 @@ local function catspawn(pos)
return prob
end
local function reg(id, base, spot)
local txr = "nc_cats_base.png^[multiply:" .. base
if base ~= spot then
txr = txr .. "^(nc_cats_spots.png^[multiply:" .. spot .. ")"
end
local basedef = {
function myapi.register_cat(id, basetiles, basedef)
basetiles = basetiles or basedef.tiles
basetiles[2] = basetiles[2] or (basetiles[1] .. "^[transformR90")
basetiles[3] = basetiles[3] or (basetiles[1] .. "^[transformFX")
basetiles[4] = basetiles[4] or basetiles[1]
basetiles[5] = basetiles[5] or basetiles[3]
basetiles[6] = basetiles[6] or basetiles[1]
basedef = nodecore.underride(basedef or {}, {
description = "Cat",
tiles = {
txr .. "^nc_cats_ears.png",
txr .. "^[transformR90^nc_cats_paws_front.png^nc_cats_paws_back.png",
txr .. "^[transformFX",
txr,
txr .. "^[transformFX^nc_cats_tail.png",
txr .. "^nc_cats_face.png",
basetiles[1] .. "^nc_cats_ears.png",
basetiles[2] .. "^nc_cats_paws_front.png^nc_cats_paws_back.png",
basetiles[3],
basetiles[4],
basetiles[5] .. "^nc_cats_tail.png",
basetiles[6] .. "^nc_cats_face.png",
},
groups = {
snappy = 1,
@ -137,7 +139,7 @@ local function reg(id, base, spot)
checksnake(p)
end
end
}
})
minetest.register_node(modname .. ":cat_" .. id, nodecore.underride({
groups = {
[modname .. "_face"] = 1
@ -148,12 +150,12 @@ local function reg(id, base, spot)
nodecore.underride({
description = "LongCat",
tiles = {
txr .. "^nc_cats_ears.png",
txr .. "^nc_cats_paws_front.png",
txr,
txr,
txr,
txr .. "^nc_cats_face.png",
basetiles[1] .. "^nc_cats_ears.png",
basetiles[2] .. "^nc_cats_paws_front.png",
basetiles[3],
basetiles[4],
basetiles[5],
basetiles[6] .. "^nc_cats_face.png",
},
groups = {
falling_node = 0,
@ -166,12 +168,12 @@ local function reg(id, base, spot)
nodecore.underride({
description = "LongCat",
tiles = {
txr,
txr .. "^nc_cats_paws_mid.png",
txr,
txr,
txr,
txr,
basetiles[1],
basetiles[2] .. "^nc_cats_paws_mid.png",
basetiles[3],
basetiles[4],
basetiles[5],
basetiles[6],
},
groups = {
falling_node = 0,
@ -183,12 +185,12 @@ local function reg(id, base, spot)
nodecore.underride({
description = "LongCat",
tiles = {
txr,
txr .. "^nc_cats_paws_back.png",
txr,
txr,
txr .. "^nc_cats_tail.png",
txr,
basetiles[1],
basetiles[2] .. "^nc_cats_paws_back.png",
basetiles[3],
basetiles[4],
basetiles[5] .. "^nc_cats_tail.png",
basetiles[6],
},
groups = {
falling_node = 0,
@ -198,6 +200,15 @@ local function reg(id, base, spot)
}, basedef))
end
local function reg(id, base, spot)
local txr = "nc_cats_base.png^[multiply:" .. base
if base ~= spot then
txr = txr .. "^(nc_cats_spots.png^[multiply:" .. spot .. ")"
end
return myapi.register_cat(id, {txr})
end
myapi.register_cat_spots = reg
reg(1, "#c0c0c0", "#404040") -- light gray
reg(2, "#404040", "#202020") -- mid gray
reg(3, "#202020", "#101010") -- dark gray