diff --git a/README.md b/README.md index acf162c1..7ac0151a 100644 --- a/README.md +++ b/README.md @@ -28,7 +28,7 @@ The game includes the mods from the default [minetest_game](https://github.com/m * [christmas][] ([MIT][lic.christmas]) -- version [d3bd872 Git][ver.christmas] *2013-01-11* ([patched][patch.christmas]) * [elevator][] ([WTFPL][lic.elevator]) * [fort_spikes][] ([MIT][lic.fort_spikes] / [CC0][lic.cc0]) -- version: [3b98b46 Git][ver.fort_spikes] *2018-06-05* - * [glass][] ([LGPL][lic.lgpl2.1] / [CC BY-SA][lic.ccbysa3.0]) -- version: [678ed5f Git][ver.glass] *2021-04-19* + * [glass][] ([LGPL][lic.lgpl2.1]) -- version: [1.0][ver.glass] *2021-04-19* * [moreblocks][] ([zlib][lic.moreblocks]) -- version: [3b97ea5 Git][ver.moreblocks] *2021-03-19* * [windmill][] ([WTFPL][lic.windmill]) -- version: [47b029d Git][ver.windmill] *2014-08-21* ([patched][patch.windmill]) * [campfire][] ([GPL][lic.gpl2.0] / [CC BY-SA][lic.ccbysa] / [WTFPL][lic.campfire]) -- version: [1058f1d Git][ver.campfire] *2019-11-28* @@ -465,7 +465,7 @@ The game includes the mods from the default [minetest_game](https://github.com/m [ver.fort_spikes]: https://github.com/xeranas/fort_spikes/tree/3b98b46 [ver.gems_encrustable]: https://github.com/wowiamdiamonds/gems/tree/81d513d [ver.gems_tools]: https://github.com/captainLAD/gems/tree/b375432 -[ver.glass]: https://github.com/AntumMT/mod-glass/tree/678ed5f +[ver.glass]: https://github.com/AntumMT/mod-glass/releases/tag/v1.0 [ver.glow]: https://github.com/bdjnk/glow/tree/4c015a0 [ver.hbarmor]: http://repo.or.cz/minetest_hbarmor.git/tree/93d994c [ver.hbsprint]: https://github.com/tacotexmex/hbsprint/tree/f566d0f diff --git a/mods/buildings/glass/LICENSE.md b/mods/buildings/glass/LICENSE.md index a65ccb81..f931fa29 100644 --- a/mods/buildings/glass/LICENSE.md +++ b/mods/buildings/glass/LICENSE.md @@ -7,30 +7,5 @@ Originally by celeron55, Perttu Ahola ([LGPL 2.1][lic.lgpl]) Various Minetest developers and contributors ([LGPL 2.1][lic.lgpl]) ---- -### **Media:** - -- Mito551, ***CC BY-SA 3.0:*** - - glass_footstep.ogg - -- Glass breaking sounds, ***CC BY 3.0:*** - - [glass_break.1.ogg](http://www.freesound.org/people/cmusounddesign/sounds/71947) by cmusounddesign - - [glass_break.2.ogg](http://www.freesound.org/people/Tomlija/sounds/97669) by Tomlija - - [glass_break.3.ogg](http://www.freesound.org/people/lsprice/sounds/88808) by lsprice - - ---- -### **Textures:** - -- Perttu Ahola ([celeron55](mailto:celeron55@gmail.com)), ***CC BY-SA 3.0:*** - - glass_obsidian_detail.png - - glass_plain.png - -- Calinou, ***CC BY-SA 3.0:*** - - glass_plain_detail.png - -- PilzAdam, ***CC BY-SA 3.0:*** - - glass_obsidian.png - [lic.lgpl]: docs/license-LGPL-2.1.txt diff --git a/mods/buildings/glass/README.md b/mods/buildings/glass/README.md index 4ab297ef..df4c4876 100644 --- a/mods/buildings/glass/README.md +++ b/mods/buildings/glass/README.md @@ -14,7 +14,7 @@ Minetest mod that replaces glass nodes from the [default][] mod in [minetest_gam ### **Features:** - Creates glass-like nodes. -- If *[unifieddyes][]* is present, nodes can be colored with dyes. +- If *[unifieddyes][]* is present, nodes can be colored with `unifieddyes:airbrush`. - Compatible with *[default][]* mod. diff --git a/mods/buildings/glass/functions.lua b/mods/buildings/glass/functions.lua index 298552c2..60b694d7 100644 --- a/mods/buildings/glass/functions.lua +++ b/mods/buildings/glass/functions.lua @@ -22,13 +22,13 @@ --- Retrieves sounds for glass nodes. -- -- @function glass.node_sounds --- @tparam table table -function glass.node_sounds(table) - table = table or {} - table.footstep = table.footstep or {name='glass_footstep', gain=0.3} - table.dig = table.dig or {name='glass_footstep', gain=0.5} - table.dug = table.dug or {name='glass_break', gain=1.0} +-- @tparam tbl table +function glass.node_sounds(tbl) + tbl = tbl or {} + tbl.footstep = tbl.footstep or {name='glass_footstep', gain=0.3} + tbl.dig = tbl.dig or {name='glass_footstep', gain=0.5} + tbl.dug = tbl.dug or {name='glass_break', gain=1.0} - default.node_sound_defaults(table) - return table + default.node_sound_defaults(tbl) + return tbl end diff --git a/mods/buildings/glass/mod.conf b/mods/buildings/glass/mod.conf index 9840a783..db26ab52 100644 --- a/mods/buildings/glass/mod.conf +++ b/mods/buildings/glass/mod.conf @@ -1,6 +1,6 @@ name = glass description = Enhances default glass to make it colorable. -version = 0.2 +version = 1.0 author = Jordan Irwin (AntumDeluge) depends = default optional_depends = unifieddyes diff --git a/mods/buildings/glass/nodes.lua b/mods/buildings/glass/nodes.lua index 670c74d0..d6189bdb 100644 --- a/mods/buildings/glass/nodes.lua +++ b/mods/buildings/glass/nodes.lua @@ -20,103 +20,72 @@ local S = core.get_translator() local enable_colors = core.global_exists('unifieddyes') or core.get_modpath('unifieddyes') -local function dig_glass(pos, node, digger) - local inv = digger:get_inventory() - local can_dig = not core.is_protected(pos, digger:get_player_name()) - local drops = {} - - if digger:is_player() then - local meta = core.get_meta(pos) - - if can_dig then - if not inv:room_for_item('main', node.name) then - table.insert(drops, node.name) - else - inv:add_item('main', node.name) - end - - if meta then - local dye = meta:get_string('dye') - - if dye and dye ~= '' then - if not inv:room_for_item('main', dye) then - table.insert(drops, dye) - else - inv:add_item('main', dye) - end - end - end - end +--- Extracts glass type from string. +-- +-- @function get_glass_type +-- @local +-- @param g string to be parsed +-- @return string representing glass type or `nil` +local function get_glass_type(g) + local glass_type = nil + local idx = g:find(':') + if idx then + glass_type = g:sub(idx+1) end - if can_dig then - core.remove_node(pos) - core.handle_node_drops(pos, drops, digger) + idx = glass_type:find('_glass') + if idx then + glass_type = glass_type:sub(1, idx-1) end + + if glass_type == 'glass' then + glass_type = 'plain' + end + + return glass_type end -local glass_def = { - description = S('Glass'), - drawtype = 'glasslike_framed_optional', - tiles = {'glass_plain.png', 'glass_plain_detail.png'}, - paramtype = 'light', - paramtype2 = 'glasslikeliquidlevel', - sunlight_propagates = true, - is_ground_content = false, - groups = {cracky=3, oddly_breakable_by_hand=3}, - sounds = glass.node_sounds(), -} - if enable_colors then - glass_def.paramtype2 = 'color' - glass_def.palette = 'unifieddyes_palette_extended.png' - glass_def.groups['ud_param2_colorable'] = 1 - glass_def.on_dig = dig_glass -end - - ---- Plain glass. --- --- @node glass:plain -core.register_node('glass:plain', glass_def) - - ---- Obsidian glass. --- --- @node glass:obsidian -core.register_node('glass:obsidian', { - description = S('Obsidian Glass'), - drawtype = 'glasslike_framed_optional', - tiles = {'glass_obsidian.png', 'glass_obsidian_detail.png'}, - paramtype = 'light', - paramtype2 = 'glasslikeliquidlevel', - sunlight_propagates = true, - is_ground_content = false, - groups = {cracky=3, oddly_breakable_by_hand=3}, - sounds = glass.node_sounds(), -}) - - --- Compatibility - -if core.get_modpath('default') then - local glass_overrides = { - 'glass', - 'obsidian_glass', + local to_color = { + 'default:glass', + 'default:obsidian_glass', } - for _, item in pairs(glass_overrides) do - core.unregister_item(item) - core.registered_nodes[item] = nil - core.registered_aliases[item] = nil + for _, old_glass in ipairs(to_color) do + local glass_type = get_glass_type(old_glass) + if not glass_type then goto continue end + local new_glass = 'glass:' .. glass_type + + local glass_def = {} + for k, v in pairs(core.registered_nodes[old_glass]) do + glass_def[k] = v + end + + glass_def.paramtype2 = 'color' + glass_def.palette = 'unifieddyes_palette_extended.png' + glass_def.groups['ud_param2_colorable'] = 1 + glass_def.on_dig = unifieddyes.on_dig + + -- register new node + core.register_node(new_glass, glass_def) + + -- unregister old node + core.unregister_item(old_glass) + core.registered_nodes[old_glass] = nil + core.registered_aliases[old_glass] = nil + core.register_alias(old_glass, new_glass) + + ::continue:: + end + + -- misc. aliases + if core.registered_nodes['glass:plain'] then + core.register_alias('glass', 'glass:plain') + core.register_alias('glass:glass', 'glass:plain') + end + + if core.registered_nodes['glass:obsidian'] then + core.register_alias('obsidian_glass', 'glass:obsidian') end end - -core.register_alias('glass', 'glass:plain') -core.register_alias('glass:glass', 'glass:plain') -core.register_alias('obsidian_glass', 'glass:obsidian') - --- Nodes from 'default' -core.register_alias_force('default:glass', 'glass:plain') -core.register_alias_force('default:obsidian_glass', 'glass:obsidian') diff --git a/mods/buildings/glass/sounds/glass_break.1.ogg b/mods/buildings/glass/sounds/glass_break.1.ogg deleted file mode 100644 index b1ccc5fa..00000000 Binary files a/mods/buildings/glass/sounds/glass_break.1.ogg and /dev/null differ diff --git a/mods/buildings/glass/sounds/glass_break.2.ogg b/mods/buildings/glass/sounds/glass_break.2.ogg deleted file mode 100644 index b6cc9e85..00000000 Binary files a/mods/buildings/glass/sounds/glass_break.2.ogg and /dev/null differ diff --git a/mods/buildings/glass/sounds/glass_break.3.ogg b/mods/buildings/glass/sounds/glass_break.3.ogg deleted file mode 100644 index ae6a6bfc..00000000 Binary files a/mods/buildings/glass/sounds/glass_break.3.ogg and /dev/null differ diff --git a/mods/buildings/glass/sounds/glass_footstep.ogg b/mods/buildings/glass/sounds/glass_footstep.ogg deleted file mode 100644 index 191287a3..00000000 Binary files a/mods/buildings/glass/sounds/glass_footstep.ogg and /dev/null differ diff --git a/mods/buildings/glass/textures/glass_obsidian.png b/mods/buildings/glass/textures/glass_obsidian.png deleted file mode 100644 index d5ac83d0..00000000 Binary files a/mods/buildings/glass/textures/glass_obsidian.png and /dev/null differ diff --git a/mods/buildings/glass/textures/glass_obsidian_detail.png b/mods/buildings/glass/textures/glass_obsidian_detail.png deleted file mode 100644 index a8bbec98..00000000 Binary files a/mods/buildings/glass/textures/glass_obsidian_detail.png and /dev/null differ diff --git a/mods/buildings/glass/textures/glass_plain.png b/mods/buildings/glass/textures/glass_plain.png deleted file mode 100644 index da254028..00000000 Binary files a/mods/buildings/glass/textures/glass_plain.png and /dev/null differ diff --git a/mods/buildings/glass/textures/glass_plain_detail.png b/mods/buildings/glass/textures/glass_plain_detail.png deleted file mode 100644 index d38dbb7b..00000000 Binary files a/mods/buildings/glass/textures/glass_plain_detail.png and /dev/null differ