diff --git a/node.lua b/node.lua index ccbcfe4..2dede6c 100644 --- a/node.lua +++ b/node.lua @@ -1,6 +1,6 @@ -- LUALOCALS < --------------------------------------------------------- -local ipairs, math, minetest, nodecore, type, vector - = ipairs, math, minetest, nodecore, type, vector +local ipairs, math, minetest, nodecore, pairs, type, vector + = ipairs, math, minetest, nodecore, pairs, type, vector local math_random = math.random -- LUALOCALS > --------------------------------------------------------- @@ -80,7 +80,7 @@ end local function catspawn(pos) local prob = 1 for _, np in ipairs(nodecore.find_nodes_around(pos, - {"group:" .. modname .. "_cat"}, 2)) do + {"group:" .. modname .. "_cat"}, 2)) do if getcatid(minetest.get_node(np)) == id then prob = prob * 1.2 end @@ -96,56 +96,58 @@ function myapi.register_cat(id, basetiles, basedef) basetiles[5] = basetiles[5] or basetiles[3] basetiles[6] = basetiles[6] or basetiles[1] basedef = nodecore.underride(basedef or {}, { - description = "Cat", - tiles = { - 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, - falling_node = 1, - [modname .. "_cat"] = id - }, - stack_max = 1, - paramtype2 = "facedir", - on_place = function(stack, placer, pointed, inf, orient, ...) - orient = orient or {} - orient.invert_wall = pointed.above.y == pointed.under.y - return minetest.rotate_and_place(stack, placer, pointed, inf, orient, ...) - end, - sounds = nodecore.sounds(modname .. "_mew"), - drop = modname .. ":cat_" .. id, - preserve_metadata = function(_, _, oldmeta, drops) - if oldmeta.realname then - oldmeta.description = oldmeta.realname - oldmeta.realname = nil + description = "Cat", + tiles = { + 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, + falling_node = 1, + [modname .. "_cat"] = id + }, + stack_max = 1, + paramtype2 = "facedir", + on_place = function(stack, placer, pointed, inf, orient, ...) + orient = orient or {} + orient.invert_wall = pointed.above.y == pointed.under.y + return minetest.rotate_and_place(stack, placer, pointed, inf, orient, ...) + end, + sounds = nodecore.sounds(modname .. "_mew"), + drop = modname .. ":cat_" .. id, + preserve_metadata = function(_, _, oldmeta, drops) + if oldmeta.realname then + oldmeta.description = oldmeta.realname + oldmeta.realname = nil + end + drops[1]:get_meta():from_table({fields = oldmeta}) + end, + after_place_node = function(pos, _, itemstack) + local node = checkfacedir(pos) + local meta = minetest.get_meta(pos) + meta:from_table(itemstack:get_meta():to_table()) + myapi.setname(meta) + checksnake(pos, node) + end, + after_destruct = function(pos) + for _, dir in ipairs(nodecore.dirs()) do + local p = vector.add(pos, dir) + checksnake(p) + end end - drops[1]:get_meta():from_table({fields = oldmeta}) - end, - after_place_node = function(pos, _, itemstack) - local node = checkfacedir(pos) - local meta = minetest.get_meta(pos) - meta:from_table(itemstack:get_meta():to_table()) - myapi.setname(meta) - checksnake(pos, node) - end, - after_destruct = function(pos) - for _, dir in ipairs(nodecore.dirs()) do - local p = vector.add(pos, dir) - checksnake(p) - end - end - }) - minetest.register_node(modname .. ":cat_" .. id, nodecore.underride({ - groups = { - [modname .. "_face"] = 1 - }, - [modname .. "_spawn_probability"] = catspawn, - }, basedef)) + }) + minetest.register_node(modname .. ":cat_" .. id, nodecore.underride( + nodecore.underride({ + groups = { + [modname .. "_face"] = 1 + }, + }, basedef), { + [modname .. "_spawn_probability"] = catspawn + })) minetest.register_node(modname .. ":longcat_front_" .. id, nodecore.underride({ description = "LongCat", @@ -217,6 +219,20 @@ reg(5, "#e0c040", "#ff8000") -- light orange reg(6, "#804000", "#402000") -- dark brown reg(7, "#c0a080", "#806020") -- light brown +do + local rbc = "nc_cats_rainbow.png^(nc_cats_rainbow.png^[multiply:#808080^[mask:nc_cats_spots.png)" + myapi.register_cat(100, { + rbc, + rbc, + rbc, + rbc, + rbc .. "^[transformFX", + rbc .. "^[transformFX", + }, { + [modname .. "_spawn_probability"] = false + }) +end + function myapi.makecat(pos, param2, creator) local all = {} for k, v in pairs(minetest.registered_nodes) do diff --git a/textures/nc_cats_rainbow.png b/textures/nc_cats_rainbow.png new file mode 100644 index 0000000..b81fe5a Binary files /dev/null and b/textures/nc_cats_rainbow.png differ