From 2c9ea6faca37fa45a418f0be6f2307ff4a2eaed1 Mon Sep 17 00:00:00 2001 From: mckaygerhard Date: Mon, 29 Apr 2024 10:29:47 -0400 Subject: [PATCH] workaround for bulk_set_node newer implementations on onder engines * the `bulk_set_node` seems the function is since minetest 5.0 but it seems does not show in the git-shit-hub search, so found it manually at https://github.com/minetest/minetest/commit/584d00a01c4bcd359cc3e585dbcab5cada662348 that is only an optimized bulk way of `set_node` using a list of positions now with this pyramids will work in older versions of minetest too * Closes https://codeberg.org/minetest-stuffs/minetest-mod-tsm_pyramids/issues/5 * incorporate a detection of 5.4+ versions of engine --- init.lua | 18 ++++++++++++++++-- room.lua | 6 +++++- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/init.lua b/init.lua index 05ebfb8..4e242c3 100644 --- a/init.lua +++ b/init.lua @@ -34,9 +34,12 @@ local PYRA_MIN_Y = 1 local PYRA_MAX_Y = 1000 -- minetest 5.x check local is_50 = minetest.has_feature("object_use_texture_alpha") +-- minetest 5.5 check +local is_54 = minetest.has_feature("use_texture_alpha_string_modes") or nil tsm_pyramids = {} tsm_pyramids.is_50 = is_50 +tsm_pyramids.is_54 = is_54 tsm_pyramids.S = S tsm_pyramids.perlin1 = nil -- perlin noise buffer, make it global cos we need to acess in 5.0 after load all the rest of mods @@ -220,6 +223,17 @@ local function make_entrance(pos, rot, brick, sand, flood_sand) end end +local wa_bulk_set_node +if not minetest.bulk_set_node then + wa_bulk_set_node = function(poslist, nodename) + for _, pos in ipairs(poslist) do + minetest.set_node(pos, nodename) + end + end +else + wa_bulk_set_node = minetest.bulk_set_node +end + local function make_pyramid(pos, brick, sandstone, stone, sand) local set_to_brick = {} local set_to_stone = {} @@ -234,8 +248,8 @@ local function make_pyramid(pos, brick, sandstone, stone, sand) end end end - minetest.bulk_set_node(set_to_stone , {name=stone}) - minetest.bulk_set_node(set_to_brick, {name=brick}) + wa_bulk_set_node(set_to_stone, {name=stone}) + wa_bulk_set_node(set_to_brick, {name=brick}) end local function make(pos, brick, sandstone, stone, sand, ptype, room_id) diff --git a/room.lua b/room.lua index dcb1cab..5a56886 100644 --- a/room.lua +++ b/room.lua @@ -1183,6 +1183,10 @@ function tsm_pyramids.flood_sand(pos, stype) end end end - minetest.bulk_set_node(set_to_sand, {name=nn}) + if tsm_pyramids.is_54 then + minetest.bulk_set_node(set_to_sand, {name=nn}) + else + for _, xpos in ipairs(set_to_sand) do minetest.set_node(xpos, {name=nn}) end + end end