Convert over to full param2 coloring (#2)
This commit is contained in:
parent
a7d7f51dab
commit
fee6e6194b
@ -1,2 +1,3 @@
|
|||||||
default
|
default
|
||||||
dye?
|
unifieddyes
|
||||||
|
dye
|
||||||
|
214
init.lua
214
init.lua
@ -1,4 +1,4 @@
|
|||||||
-- Minetest 0.4.7 mod: framedglass
|
-- Minetest 0.4.17 mod: framedglass
|
||||||
|
|
||||||
framedglass = {}
|
framedglass = {}
|
||||||
|
|
||||||
@ -68,147 +68,91 @@ minetest.register_node("framedglass:wooden_framed_obsidian_glass", {
|
|||||||
sounds = default.node_sound_glass_defaults(),
|
sounds = default.node_sound_glass_defaults(),
|
||||||
})
|
})
|
||||||
|
|
||||||
-- helper functions copied partly from Unified Dyes
|
|
||||||
|
|
||||||
local creative_mode = minetest.setting_getbool("creative_mode")
|
|
||||||
|
|
||||||
local function select_node(pointed_thing)
|
|
||||||
local pos = pointed_thing.under
|
|
||||||
local node = minetest.get_node_or_nil(pos)
|
|
||||||
local def = node and minetest.registered_nodes[node.name]
|
|
||||||
|
|
||||||
if not def or not def.buildable_to then
|
|
||||||
pos = pointed_thing.above
|
|
||||||
node = minetest.get_node_or_nil(pos)
|
|
||||||
def = node and minetest.registered_nodes[node.name]
|
|
||||||
end
|
|
||||||
return def and pos, def
|
|
||||||
end
|
|
||||||
|
|
||||||
local function is_buildable_to(placer_name, ...)
|
|
||||||
for _, pos in ipairs({...}) do
|
|
||||||
local node = minetest.get_node_or_nil(pos)
|
|
||||||
local def = node and minetest.registered_nodes[node.name]
|
|
||||||
if not (def and def.buildable_to) or minetest.is_protected(pos, placer_name) then
|
|
||||||
return false
|
|
||||||
end
|
|
||||||
end
|
|
||||||
return true
|
|
||||||
end
|
|
||||||
|
|
||||||
function framedglass.color_on_punch(pos, node, puncher, pointed_thing)
|
|
||||||
local itemstack = puncher:get_wielded_item()
|
|
||||||
local itemname = itemstack:get_name()
|
|
||||||
|
|
||||||
if not string.find(itemname, "dye:")
|
|
||||||
and not string.find(itemname, "unifieddyes:") then
|
|
||||||
return itemstack
|
|
||||||
end
|
|
||||||
|
|
||||||
local a,b = string.find(node.name, "_glass")
|
|
||||||
local oldcolor = string.sub(node.name, b + 1)
|
|
||||||
local newcolor = string.sub(itemname, string.find(itemname, ":") + 1)
|
|
||||||
|
|
||||||
local oldcolor2 = string.gsub(oldcolor, "darkgreen", "dark_green")
|
|
||||||
local oldcolor2 = string.gsub(oldcolor2, "darkgrey", "dark_grey")
|
|
||||||
|
|
||||||
local newcolor2 = string.gsub(newcolor, "dark_green", "darkgreen")
|
|
||||||
local newcolor2 = string.gsub(newcolor2, "dark_grey", "darkgrey")
|
|
||||||
|
|
||||||
if oldcolor == newcolor2 then
|
|
||||||
minetest.chat_send_player(puncher:get_player_name(), "That node is already "..newcolor.."." )
|
|
||||||
return itemstack
|
|
||||||
end
|
|
||||||
|
|
||||||
if not (newcolor == "dark_grey"
|
|
||||||
or newcolor == "dark_green"
|
|
||||||
or minetest.registered_nodes["framedglass:steel_framed_obsidian_glass"..newcolor]) then
|
|
||||||
minetest.chat_send_player(puncher:get_player_name(), "Framed glass doesn't support "..newcolor.."." )
|
|
||||||
return itemstack
|
|
||||||
end
|
|
||||||
|
|
||||||
local inv = puncher:get_inventory()
|
|
||||||
local prevdye = "dye:"..oldcolor2
|
|
||||||
|
|
||||||
if not (inv:contains_item("main", prevdye) and creative_mode) and minetest.registered_items[prevdye] then
|
|
||||||
if inv:room_for_item("main", prevdye) then
|
|
||||||
inv:add_item("main", prevdye)
|
|
||||||
else
|
|
||||||
minetest.add_item(pos, prevdye)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
minetest.set_node(pos, { name = "framedglass:steel_framed_obsidian_glass"..newcolor2 })
|
|
||||||
itemstack:take_item()
|
|
||||||
return itemstack
|
|
||||||
end
|
|
||||||
|
|
||||||
local return_dye_after_dig = function(pos, oldnode, oldmetadata, digger)
|
|
||||||
|
|
||||||
local a,b = string.find(oldnode.name, "_glass")
|
|
||||||
local oldcolor = string.sub(oldnode.name, b + 1)
|
|
||||||
local oldcolor2 = string.gsub(oldcolor, "darkgreen", "dark_green")
|
|
||||||
local oldcolor2 = string.gsub(oldcolor2, "darkgrey", "dark_grey")
|
|
||||||
|
|
||||||
local prevdye = "dye:"..oldcolor2
|
|
||||||
|
|
||||||
local inv = digger:get_inventory()
|
|
||||||
|
|
||||||
if prevdye and not (inv:contains_item("main", prevdye) and creative_mode) and minetest.registered_items[prevdye] then
|
|
||||||
if inv:room_for_item("main", prevdye) then
|
|
||||||
inv:add_item("main", prevdye)
|
|
||||||
else
|
|
||||||
minetest.add_item(pos, prevdye)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
minetest.register_node("framedglass:steel_framed_obsidian_glass", {
|
minetest.register_node("framedglass:steel_framed_obsidian_glass", {
|
||||||
description = "Steel-framed Obsidian Glass",
|
description = "Steel-framed Obsidian Glass",
|
||||||
drawtype = "glasslike_framed",
|
drawtype = "glasslike_framed",
|
||||||
tiles = {"framedglass_steel_frame.png","framedglass_glass_face_clean.png"},
|
tiles = {"framedglass_steel_frame.png", "framedglass_glass_face_clean.png"},
|
||||||
paramtype = "light",
|
paramtype = "light",
|
||||||
sunlight_propagates = true,
|
sunlight_propagates = true,
|
||||||
groups = {cracky=3,oddly_breakable_by_hand=3},
|
palette = "unifieddyes_palette_extended.png",
|
||||||
|
airbrush_replacement_node = "framedglass:steel_framed_obsidian_glass_tinted",
|
||||||
|
groups = {cracky=3, oddly_breakable_by_hand=3, ud_param2_colorable = 1},
|
||||||
sounds = default.node_sound_glass_defaults(),
|
sounds = default.node_sound_glass_defaults(),
|
||||||
on_punch = framedglass.color_on_punch,
|
|
||||||
after_dig_node = return_dye_after_dig
|
|
||||||
})
|
})
|
||||||
|
|
||||||
function add_coloured_framedglass(name, desc, color)
|
minetest.register_node("framedglass:steel_framed_obsidian_glass_tinted", {
|
||||||
minetest.register_node( "framedglass:steel_framed_obsidian_glass"..name, {
|
description = "Steel-framed Obsidian Glass",
|
||||||
description = "Steel-framed "..desc.." Obsidian Glass",
|
drawtype = "glasslike_framed",
|
||||||
tiles = {
|
tiles = {
|
||||||
"framedglass_steel_frame.png",
|
{ name = "framedglass_steel_frame.png", color = "white" },
|
||||||
{ name = "framedglass_whiteglass.png", color = color }
|
"framedglass_whiteglass.png",
|
||||||
},
|
},
|
||||||
drawtype = "glasslike_framed",
|
palette = "unifieddyes_palette_extended.png",
|
||||||
paramtype = "light",
|
inventory_image = minetest.inventorycube("framedglass_glass_face_inv_static.png"),
|
||||||
sunlight_propagates = true,
|
paramtype = "light",
|
||||||
is_ground_content = true,
|
paramtype2 = "color",
|
||||||
use_texture_alpha = true,
|
sunlight_propagates = true,
|
||||||
groups = {cracky=3, not_in_creative_inventory=1},
|
is_ground_content = true,
|
||||||
sounds = default.node_sound_glass_defaults(),
|
use_texture_alpha = true,
|
||||||
on_punch = framedglass.color_on_punch,
|
groups = {cracky=3, oddly_breakable_by_hand=3, ud_param2_colorable = 1, not_in_creative_inventory = 1},
|
||||||
after_dig_node = return_dye_after_dig,
|
sounds = default.node_sound_glass_defaults(),
|
||||||
drop = "framedglass:steel_framed_obsidian_glass"
|
})
|
||||||
})
|
|
||||||
|
-- crafts!
|
||||||
|
|
||||||
|
unifieddyes.register_color_craft({
|
||||||
|
output = "framedglass:steel_framed_obsidian_glass_tinted",
|
||||||
|
type = "shapeless",
|
||||||
|
palette = "extended",
|
||||||
|
neutral_node = "framedglass:steel_framed_obsidian_glass",
|
||||||
|
recipe = {
|
||||||
|
"NEUTRAL_NODE",
|
||||||
|
"MAIN_DYE"
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
-- Convert old nodes
|
||||||
|
|
||||||
|
local static_colors = {
|
||||||
|
red = 4*24 ,
|
||||||
|
orange = 4*24 + 2,
|
||||||
|
yellow = 4*24 + 4,
|
||||||
|
green = 4*24 + 8,
|
||||||
|
cyan = 4*24 + 12,
|
||||||
|
blue = 4*24 + 16,
|
||||||
|
violet = 4*24 + 18,
|
||||||
|
magenta = 4*24 + 20,
|
||||||
|
darkgreen = 8*24 + 8,
|
||||||
|
pink = 23,
|
||||||
|
brown = 8*24 + 2,
|
||||||
|
white = 10*24 ,
|
||||||
|
grey = 10*24 + 7,
|
||||||
|
darkgrey = 10*24 + 11,
|
||||||
|
black = 10*24 + 15
|
||||||
|
}
|
||||||
|
|
||||||
|
local old_nodes = {}
|
||||||
|
for k, v in pairs(static_colors) do
|
||||||
|
table.insert(old_nodes, "framedglass:steel_framed_obsidian_glass" .. k)
|
||||||
end
|
end
|
||||||
|
|
||||||
add_coloured_framedglass ("red", "Red", 0xffff0000)
|
minetest.register_lbm({
|
||||||
add_coloured_framedglass ("orange", "Orange", 0xfffe7f00)
|
label = "Convert old framedglass static-colored nodes",
|
||||||
add_coloured_framedglass ("yellow", "Yellow", 0xffffff01)
|
name = "framedglass:convert_static",
|
||||||
add_coloured_framedglass ("green", "Green", 0xff0cff00)
|
run_at_every_load = false,
|
||||||
add_coloured_framedglass ("cyan", "Cyan", 0xff7affff)
|
nodenames = old_nodes,
|
||||||
add_coloured_framedglass ("blue", "Blue", 0xff1600ff)
|
action = function(pos, node)
|
||||||
add_coloured_framedglass ("violet", "Violet", 0xff7d00ff)
|
local oldcolor = string.sub(node.name, 40)
|
||||||
add_coloured_framedglass ("magenta", "Magenta", 0xfffd05ff)
|
if oldcolor then
|
||||||
|
minetest.swap_node(pos, {
|
||||||
add_coloured_framedglass ("darkgreen", "Dark Green", 0xff144f00)
|
name = "framedglass:steel_framed_obsidian_glass_tinted",
|
||||||
add_coloured_framedglass ("pink", "Pink", 0xffffa4a4)
|
param2 = static_colors[oldcolor]
|
||||||
add_coloured_framedglass ("brown", "Brown", 0xff542a00)
|
})
|
||||||
|
else
|
||||||
add_coloured_framedglass ("white", "White", 0xffffffff)
|
minetest.swap_node(pos, {
|
||||||
add_coloured_framedglass ("grey", "Grey", 0xff7f817e)
|
name = "framedglass:steel_framed_obsidian_glass",
|
||||||
add_coloured_framedglass ("darkgrey", "Dark Grey", 0xff3f403e)
|
param2 = 0
|
||||||
add_coloured_framedglass ("black", "Black", 0xff000000)
|
})
|
||||||
|
end
|
||||||
|
end
|
||||||
|
})
|
||||||
|
BIN
textures/framedglass_glass_face_inv_static.png
Normal file
BIN
textures/framedglass_glass_face_inv_static.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 474 B |
Loading…
x
Reference in New Issue
Block a user