Skip to content

Commit

Permalink
autodetect 5.4/5.X/0.4 version and set deprecation of some things
Browse files Browse the repository at this point in the history
* detect is_50 for 5.0+
* detect is_54 for 5.4+
* Fix deprecated use of `use_texture_alpha` on 5.4+
* Pending related minetest-mods#187
  • Loading branch information
mckaygerhard committed Feb 19, 2022
1 parent 1410da4 commit 2f51b23
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 14 deletions.
7 changes: 4 additions & 3 deletions init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,14 @@ Licensed under the zlib license. See LICENSE.md for more information.
--]]

moreblocks = {}

local is_54 = minetest.has_feature("direct_velocity_on_players")
local is_50 = minetest.has_feature("object_use_texture_alpha")
local modpath = minetest.get_modpath("moreblocks")

local S, NS = dofile(modpath .. "/intllib.lua")
moreblocks.S = S
moreblocks.NS = NS

moreblocks.is_50 = is_50
moreblocks.is_54 = is_54
dofile(modpath .. "/config.lua")
dofile(modpath .. "/circular_saw.lua")
dofile(modpath .. "/stairsplus/init.lua")
Expand Down
21 changes: 11 additions & 10 deletions nodes.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Licensed under the zlib license. See LICENSE.md for more information.
--]]

local S = moreblocks.S

local is_54 = moreblocks.is_54
local sound_dirt = default.node_sound_dirt_defaults()
local sound_wood = default.node_sound_wood_defaults()
local sound_stone = default.node_sound_stone_defaults()
Expand All @@ -16,6 +16,7 @@ local sound_leaves = default.node_sound_leaves_defaults()
-- Don't break on 0.4.14 and earlier.
local sound_metal = (default.node_sound_metal_defaults
and default.node_sound_metal_defaults() or sound_stone)
local utaapi; if is_54 then utaapi = "clip" else utaapi = true end

local function tile_tiles(name)
local tex = "moreblocks_" ..name.. ".png"
Expand Down Expand Up @@ -194,7 +195,7 @@ local nodes = {
description = S("Iron Glass"),
drawtype = "glasslike_framed_optional",
tiles = {"default_glass.png^[colorize:#DEDEDE", "default_glass_detail.png^[colorize:#DEDEDE"},
use_texture_alpha = true,
use_texture_alpha = utaapi,
paramtype = "light",
sunlight_propagates = true,
is_ground_content = false,
Expand All @@ -205,7 +206,7 @@ local nodes = {
description = S("Coal Glass"),
drawtype = "glasslike_framed_optional",
tiles = {"default_glass.png^[colorize:#828282", "default_glass_detail.png^[colorize:#828282"},
use_texture_alpha = true,
use_texture_alpha = utaapi,
paramtype = "light",
sunlight_propagates = true,
is_ground_content = false,
Expand All @@ -216,7 +217,7 @@ local nodes = {
description = S("Clean Glass"),
drawtype = "glasslike_framed_optional",
tiles = {"moreblocks_clean_glass.png", "moreblocks_clean_glass_detail.png"},
use_texture_alpha = true,
use_texture_alpha = utaapi,
paramtype = "light",
sunlight_propagates = true,
is_ground_content = false,
Expand Down Expand Up @@ -316,7 +317,7 @@ local nodes = {
description = S("Trap Glass"),
drawtype = "glasslike_framed_optional",
tiles = {"default_glass.png^moreblocks_trap_box_glass.png", "default_glass_detail.png"},
use_texture_alpha = true,
use_texture_alpha = utaapi,
paramtype = "light",
sunlight_propagates = true,
is_ground_content = false,
Expand All @@ -329,7 +330,7 @@ local nodes = {
description = S("Trap Obsidian Glass"),
drawtype = "glasslike_framed_optional",
tiles = {"default_obsidian_glass.png^moreblocks_trap_box_glass.png", "default_obsidian_glass_detail.png"},
use_texture_alpha = true,
use_texture_alpha = utaapi,
paramtype = "light",
sunlight_propagates = true,
is_ground_content = false,
Expand Down Expand Up @@ -399,7 +400,7 @@ local nodes = {
description = S("Glow Glass"),
drawtype = "glasslike_framed_optional",
tiles = {"default_glass.png^[colorize:#E9CD61", "default_glass_detail.png^[colorize:#E9CD61"},
use_texture_alpha = true,
use_texture_alpha = utaapi,
paramtype = "light",
sunlight_propagates = true,
is_ground_content = false,
Expand All @@ -411,7 +412,7 @@ local nodes = {
description = S("Trap Glow Glass"),
drawtype = "glasslike_framed_optional",
tiles = {"default_glass.png^[colorize:#E9CD61^moreblocks_trap_box_glass.png", "default_glass_detail.png^[colorize:#E9CD61"},
use_texture_alpha = true,
use_texture_alpha = utaapi,
paramtype = "light",
sunlight_propagates = true,
is_ground_content = false,
Expand All @@ -425,7 +426,7 @@ local nodes = {
description = S("Super Glow Glass"),
drawtype = "glasslike_framed_optional",
tiles = {"default_glass.png^[colorize:#FFFF78", "default_glass_detail.png^[colorize:#FFFF78"},
use_texture_alpha = true,
use_texture_alpha = utaapi,
paramtype = "light",
sunlight_propagates = true,
is_ground_content = false,
Expand All @@ -437,7 +438,7 @@ local nodes = {
description = S("Trap Super Glow Glass"),
drawtype = "glasslike_framed_optional",
tiles = {"default_glass.png^[colorize:#FFFF78^moreblocks_trap_box_glass.png", "default_glass_detail.png^[colorize:#FFFF78"},
use_texture_alpha = true,
use_texture_alpha = utaapi,
paramtype = "light",
sunlight_propagates = true,
is_ground_content = false,
Expand Down
2 changes: 1 addition & 1 deletion redefinitions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Licensed under the zlib license. See LICENSE.md for more information.

local modname = minetest.get_current_modname()

local is_50 = minetest.has_feature("object_use_texture_alpha")
local is_50 = moreblocks.is_50

-- Redefine some of the default crafting recipes to be more productive

Expand Down

0 comments on commit 2f51b23

Please sign in to comment.