1
0
Fork 0

Add colored banners

This commit is contained in:
Wuzzy 2017-07-27 19:13:41 +02:00
parent db1d272602
commit 8320c7690e
2 changed files with 132 additions and 79 deletions

View File

@ -53,6 +53,7 @@ local group_stereotypes = {
coal = "mcl_core:coal_lump", coal = "mcl_core:coal_lump",
shulker_box = "mcl_chests:violet_shulker_box", shulker_box = "mcl_chests:violet_shulker_box",
quartz_block = "mcl_nether:quartz_block", quartz_block = "mcl_nether:quartz_block",
banner = "mcl_banners:standing_banner_white",
mesecon_conductor_craftable = "mesecons:wire_00000000_off", mesecon_conductor_craftable = "mesecons:wire_00000000_off",
compass = mcl_compass.stereotype, compass = mcl_compass.stereotype,
clock = mcl_clock.sterotype, clock = mcl_clock.sterotype,

View File

@ -9,20 +9,75 @@ local function round(num, idp)
return math.floor(num * mult + 0.5) / mult return math.floor(num * mult + 0.5) / mult
end end
-- Banner node local colors = {
minetest.register_node("mcl_banners:standing_banner_white", { -- ID, description, wool, unified dyes color group, overlay color,
description = "White Banner", ["unicolor_white"] = {"white", "White Banner", "mcl_wool:white", nil },
["unicolor_darkcolor"] = {"grey", "Grey Banner", "mcl_wool:grey", "#303030D0" },
["unicolor_grey"] = {"silver", "Light Grey Banner", "mcl_wool:silver", "#5B5B5BD0" },
["unicolor_black"] = {"black", "Black Banner", "mcl_wool:black", "#000000D0" },
["unicolor_red"] = {"red", "Red Banner", "mcl_wool:red", "#CC0000D0" },
["unicolor_yellow"] = {"yellow", "Yellow Banner", "mcl_wool:yellow", "#CCCC00D0" },
["unicolor_dark_green"] = {"green", "Green Banner", "mcl_wool:green", "#008000D0" },
["unicolor_cyan"] = {"cyan", "Cyan Banner", "mcl_wool:cyan", "#00CCCCD0" },
["unicolor_blue"] = {"blue", "Blue Banner", "mcl_wool:blue", "#0000CCD0" },
["unicolor_red_violet"] = {"magenta", "Magenta Banner", "mcl_wool:magenta", "#CC0050D0" },
["unicolor_orange"] = {"orange", "Orange Banner", "mcl_wool:orange", "#CC5000D0" },
["unicolor_violet"] = {"purple", "Purple Banner", "mcl_wool:purple", "#5000CCD0" },
["unicolor_brown"] = {"brown", "Brown Banner", "mcl_wool:brown", "#502A00D0" },
["unicolor_pink"] = {"pink", "Pink Banner", "mcl_wool:pink", "#FF5050D0" },
["unicolor_lime"] = {"lime", "Lime Banner", "mcl_wool:lime", "#50CC00D0"},
["unicolor_light_blue"] = {"light_blue", "Light Blue Banner", "mcl_wool:light_blue", "#5050FFD0" },
}
local on_destruct_standing_banner = function(pos)
local objects = minetest.get_objects_inside_radius(pos, 0.5)
for _, v in ipairs(objects) do
if v:get_entity_name() == "mcl_banners:standing_banner" then
v:remove()
end
end
end
local make_banner_texture = function(colorid)
local colorize
if colors[colorid] then
colorize = colors[colorid][4]
end
if colorize then
return { "mcl_banners_banner_base.png^((mcl_banners_banner_base.png^[mask:mcl_banners_base.png)^[colorize:"..colorize..")" }
else
return { "mcl_banners_banner_base.png" }
end
end
for colorid, colortab in pairs(colors) do
local itemid = colortab[1]
local desc = colortab[2]
local wool = colortab[3]
local colorize = colortab[4]
local itemstring_standing = "mcl_banners:standding_banner_"..itemid
local inv
if colorize then
inv = "mcl_banners_item_base.png^(mcl_banners_item_overlay.png^[colorize:"..colorize..")"
else
inv = "mcl_banners_item_base.png^mcl_banners_item_overlay.png"
end
-- Banner node
minetest.register_node(itemstring_standing, {
description = desc,
_doc_items_longdesc = "Banners are tall decorative blocks which can be placed on the floor.", _doc_items_longdesc = "Banners are tall decorative blocks which can be placed on the floor.",
walkable = false, walkable = false,
is_ground_content = false, is_ground_content = false,
paramtype = "light", paramtype = "light",
sunlight_propagates = true, sunlight_propagates = true,
drawtype = "airlike", drawtype = "airlike",
inventory_image = "mcl_banners_item_base.png^mcl_banners_item_overlay.png", inventory_image = inv,
wield_image = "mcl_banners_item_base.png^mcl_banners_item_overlay.png", wield_image = inv,
tiles = { "blank.png" },
selection_box = {type = "fixed", fixed= {-0.2, -0.5, -0.2, 0.2, 0.5, 0.2} }, selection_box = {type = "fixed", fixed= {-0.2, -0.5, -0.2, 0.2, 0.5, 0.2} },
tiles = {"mcl_banners_banner_base.png"}, groups = { banner = 1, deco_block = 1, attached_node = 1 },
groups = { deco_block = 1, attached_node = 1 },
stack_max = 16, stack_max = 16,
sounds = node_sounds, sounds = node_sounds,
@ -53,6 +108,8 @@ minetest.register_node("mcl_banners:standing_banner_white", {
place_pos.y = place_pos.y - 0.5 place_pos.y = place_pos.y - 0.5
local banner = minetest.add_entity(place_pos, "mcl_banners:standing_banner") local banner = minetest.add_entity(place_pos, "mcl_banners:standing_banner")
banner:set_properties({textures=make_banner_texture(colorid)})
banner:get_luaentity()._base_color = colorid
-- Determine the rotation based on player's yaw -- Determine the rotation based on player's yaw
local yaw = placer:get_look_horizontal() local yaw = placer:get_look_horizontal()
@ -68,25 +125,31 @@ minetest.register_node("mcl_banners:standing_banner_white", {
return itemstack return itemstack
end, end,
on_destruct = function(pos)
local objects = minetest.get_objects_inside_radius(pos, 0.5) on_destruct = on_destruct_standing_banner,
for _, v in ipairs(objects) do
if v:get_entity_name() == "mcl_banners:standing_banner" then
v:remove()
end
end
end,
_mcl_hardness = 1, _mcl_hardness = 1,
_mcl_blast_resistance = 5, _mcl_blast_resistance = 5,
}) })
if minetest.get_modpath("mcl_core") and minetest.get_modpath("mcl_wool") then
minetest.register_craft({
output = itemstring_standing,
recipe = {
{ wool, wool, wool },
{ wool, wool, wool },
{ "", "mcl_core:stick", "" },
}
})
end
end
minetest.register_entity("mcl_banners:standing_banner", { minetest.register_entity("mcl_banners:standing_banner", {
physical = false, physical = false,
collide_with_objects = false, collide_with_objects = false,
visual = "mesh", visual = "mesh",
mesh = "amc_banner.b3d", mesh = "amc_banner.b3d",
visual_size = { x=2.5, y=2.5 }, visual_size = { x=2.499, y=2.499 },
textures = { "mcl_banners_banner_base.png" }, textures = make_banner_texture(),
collisionbox = { 0, 0, 0, 0, 0, 0 }, collisionbox = { 0, 0, 0, 0, 0, 0 },
_base_color = nil, _base_color = nil,
@ -99,26 +162,15 @@ minetest.register_entity("mcl_banners:standing_banner", {
if staticdata and staticdata ~= "" then if staticdata and staticdata ~= "" then
local inp = minetest.deserialize(staticdata) local inp = minetest.deserialize(staticdata)
self._base_color = inp._base_color self._base_color = inp._base_color
self.object:set_properties({textures = make_banner_texture(self._base_color)})
end end
self.object:set_armor_groups({immortal=1}) self.object:set_armor_groups({immortal=1})
end, end,
}) })
if minetest.get_modpath("mcl_core") and minetest.get_modpath("mcl_wool") then
minetest.register_craft({
output = "mcl_banners:standing_banner_white",
recipe = {
{ "mcl_wool:white", "mcl_wool:white", "mcl_wool:white" },
{ "mcl_wool:white", "mcl_wool:white", "mcl_wool:white" },
{ "", "mcl_core:stick", "" },
}
})
end
minetest.register_craft({ minetest.register_craft({
type = "fuel", type = "fuel",
recipe = "mcl_banners:standing_banner_white", recipe = "group:banner",
burntime = 15, burntime = 15,
}) })