diff options
Diffstat (limited to 'framedglass')
-rw-r--r-- | framedglass/depends.txt | 3 | ||||
-rw-r--r-- | framedglass/init.lua | 207 | ||||
-rw-r--r-- | framedglass/textures/framedglass_glass_face_inv_static.png | bin | 0 -> 474 bytes |
3 files changed, 75 insertions, 135 deletions
diff --git a/framedglass/depends.txt b/framedglass/depends.txt index 765575d..9db6e0e 100644 --- a/framedglass/depends.txt +++ b/framedglass/depends.txt @@ -1,2 +1,3 @@ default -dye? +unifieddyes +dye diff --git a/framedglass/init.lua b/framedglass/init.lua index d42a07b..4d36165 100644 --- a/framedglass/init.lua +++ b/framedglass/init.lua @@ -1,4 +1,4 @@ --- Minetest 0.4.7 mod: framedglass +-- Minetest 0.4.17 mod: framedglass framedglass = {} @@ -68,147 +68,86 @@ minetest.register_node("framedglass:wooden_framed_obsidian_glass", { 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", { description = "Steel-framed Obsidian Glass", drawtype = "glasslike_framed", tiles = {"framedglass_steel_frame.png","framedglass_glass_face_clean.png"}, paramtype = "light", 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(), +}) + +minetest.register_node("framedglass:steel_framed_obsidian_glass_tinted", { + description = "Steel-framed Obsidian Glass", + drawtype = "glasslike_framed", + tiles = { + { name = "framedglass_steel_frame.png", color = "white" }, + "framedglass_whiteglass.png", + }, + palette = "unifieddyes_palette_extended.png", + inventory_image = minetest.inventorycube("framedglass_glass_face_inv_static.png"), + paramtype = "light", + paramtype2 = "color", + sunlight_propagates = true, + is_ground_content = true, + use_texture_alpha = true, + groups = {cracky=3,oddly_breakable_by_hand=3, ud_param2_colorable = 1, not_in_creative_inventory = 1}, 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"..name, { - description = "Steel-framed "..desc.." Obsidian Glass", - tiles = { - "framedglass_steel_frame.png", - { name = "framedglass_whiteglass.png", color = color } - }, - drawtype = "glasslike_framed", - paramtype = "light", - sunlight_propagates = true, - is_ground_content = true, - use_texture_alpha = true, - groups = {cracky=3, not_in_creative_inventory=1}, - sounds = default.node_sound_glass_defaults(), - on_punch = framedglass.color_on_punch, - after_dig_node = return_dye_after_dig, - 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 -add_coloured_framedglass ("red", "Red", 0xffff0000) -add_coloured_framedglass ("orange", "Orange", 0xfffe7f00) -add_coloured_framedglass ("yellow", "Yellow", 0xffffff01) -add_coloured_framedglass ("green", "Green", 0xff0cff00) -add_coloured_framedglass ("cyan", "Cyan", 0xff7affff) -add_coloured_framedglass ("blue", "Blue", 0xff1600ff) -add_coloured_framedglass ("violet", "Violet", 0xff7d00ff) -add_coloured_framedglass ("magenta", "Magenta", 0xfffd05ff) - -add_coloured_framedglass ("darkgreen", "Dark Green", 0xff144f00) -add_coloured_framedglass ("pink", "Pink", 0xffffa4a4) -add_coloured_framedglass ("brown", "Brown", 0xff542a00) - -add_coloured_framedglass ("white", "White", 0xffffffff) -add_coloured_framedglass ("grey", "Grey", 0xff7f817e) -add_coloured_framedglass ("darkgrey", "Dark Grey", 0xff3f403e) -add_coloured_framedglass ("black", "Black", 0xff000000) +minetest.register_lbm({ + label = "Convert old framedglass static-colored nodes", + name = "framedglass:convert_static", + run_at_every_load = false, + nodenames = old_nodes, + action = function(pos, node) + local oldcolor = string.sub(node.name, 40) + if oldcolor then + minetest.swap_node(pos, {name = "framedglass:steel_framed_obsidian_glass_tinted", + param2 = static_colors[oldcolor] }) + else + minetest.swap_node(pos, {name = "framedglass:steel_framed_obsidian_glass", param2 = 0 }) + end + end +}) diff --git a/framedglass/textures/framedglass_glass_face_inv_static.png b/framedglass/textures/framedglass_glass_face_inv_static.png Binary files differnew file mode 100644 index 0000000..ff43048 --- /dev/null +++ b/framedglass/textures/framedglass_glass_face_inv_static.png |