From dcf0b794206b33398d7ab3bc99d6cb1a72f7aaf8 Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Sat, 2 Jul 2022 15:46:04 +0200 Subject: [PATCH 01/21] Mention requirement of 'server' priv --- README.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.txt b/README.txt index c2f1251..114b084 100644 --- a/README.txt +++ b/README.txt @@ -10,7 +10,7 @@ conspicuous location, such as atop a building or along a promenade. /giveme pride_flags:mast_upper By default, a rainbow pride flag will appear when the upper mast is placed. Right-click -the node to select a different flag. +the node to select a different flag (this requires the "server" privilege). Repository From 662bc328f45fb2b585ecc28f4824f6738ec452fd Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Sat, 2 Jul 2022 15:47:13 +0200 Subject: [PATCH 02/21] Clean up init.lua a bit --- init.lua | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/init.lua b/init.lua index becbe53..e7078ac 100644 --- a/init.lua +++ b/init.lua @@ -3,8 +3,6 @@ -- -- See README.txt for licensing and other information. -- Copyright (c) 2022, Leslie E. Krause --- --- ./games/minetest_game/mods/pride_flags/init.lua -------------------------------------------------------- local wind_noise = PerlinNoise( 204, 1, 0, 500 ) @@ -67,7 +65,7 @@ minetest.register_entity( "pride_flags:wavingflag", { reset_animation = function ( self, start_frame ) local cur_wind = wind_noise:get2d( { x = os.time( ) % 65535, y = 0 } ) * 30 + 30 -print( cur_wind ) + minetest.log("verbose", "[pride_flags] Current wind: " .. cur_wind) local anim_speed local wave_sound From 7035943fc433293ce01cb6202c49f0040a913607 Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Sat, 2 Jul 2022 15:53:10 +0200 Subject: [PATCH 03/21] Rename files to match naming convention --- README.txt | 14 +++++++------- init.lua | 18 +++++++++--------- ...t_lower.obj => pride_flags_mast_lower.obj} | 0 ...t_upper.obj => pride_flags_mast_upper.obj} | 0 ...ingflag.b3d => pride_flags_wavingflag.b3d} | Bin ...lagwave1.ogg => pride_flags_flagwave1.ogg} | Bin ...lagwave2.ogg => pride_flags_flagwave2.ogg} | Bin ...lagwave3.ogg => pride_flags_flagwave3.ogg} | Bin ...aremetal.png => pride_flags_baremetal.png} | Bin 9 files changed, 16 insertions(+), 16 deletions(-) rename models/{mast_lower.obj => pride_flags_mast_lower.obj} (100%) rename models/{mast_upper.obj => pride_flags_mast_upper.obj} (100%) rename models/{wavingflag.b3d => pride_flags_wavingflag.b3d} (100%) rename sounds/{flagwave1.ogg => pride_flags_flagwave1.ogg} (100%) rename sounds/{flagwave2.ogg => pride_flags_flagwave2.ogg} (100%) rename sounds/{flagwave3.ogg => pride_flags_flagwave3.ogg} (100%) rename textures/{default_baremetal.png => pride_flags_baremetal.png} (100%) diff --git a/README.txt b/README.txt index 114b084..a3915c7 100644 --- a/README.txt +++ b/README.txt @@ -57,16 +57,16 @@ Multimedia License (textures, sounds, and models) Attribution-ShareAlike 3.0 Unported (CC BY-SA 3.0) - /models/mast_lower.obj + /models/pride_flags_mast_lower.obj by sorcerykid - /models/mast_upper.obj + /models/pride_flags_mast_upper.obj by sorcerykid - /models/wavingflag.b3d + /models/pride_flags_wavingflag.b3d by sorcerykid - /textures/default_baremetal.png + /textures/pride_flags_baremetal.png by sorcerykid /textures/prideflag_asexual.png @@ -102,17 +102,17 @@ Attribution-ShareAlike 3.0 Unported (CC BY-SA 3.0) /textures/prideflag_transgender.png by sorcerykid - /sounds/flagwave1.ogg + /sounds/pride_flags_flagwave1.ogg by Chelly01 obtained from https://freesound.org/people/Chelly01/sounds/541088/ modified by sorcerykid - /sounds/flagwave2.ogg + /sounds/pride_flags_flagwave2.ogg by Chelly01 obtained from https://freesound.org/people/Chelly01/sounds/541088/ modified by sorcerykid - /sounds/flagwave3.ogg + /sounds/pride_flags_flagwave3.ogg by Chelly01 obtained from https://freesound.org/people/Chelly01/sounds/541088/ modified by sorcerykid diff --git a/init.lua b/init.lua index e7078ac..fe94e8a 100644 --- a/init.lua +++ b/init.lua @@ -22,7 +22,7 @@ minetest.register_entity( "pride_flags:wavingflag", { collisionbox = { -0.1, -0.85, -0.1, 0.1, 0.85, 0.1 }, backface_culling = false, pointable = false, - mesh = "wavingflag.b3d", + mesh = "pride_flags_wavingflag.b3d", textures = { "prideflag_rainbow.png" }, use_texture_alpha = false, }, @@ -71,16 +71,16 @@ minetest.register_entity( "pride_flags:wavingflag", { if cur_wind < 10 then anim_speed = 10 -- 2 cycle - wave_sound = "flagwave1" + wave_sound = "pride_flags_flagwave1" elseif cur_wind < 20 then anim_speed = 20 -- 4 cycles - wave_sound = "flagwave1" + wave_sound = "pride_flags_flagwave1" elseif cur_wind < 40 then anim_speed = 40 -- 8 cycles - wave_sound = "flagwave2" + wave_sound = "pride_flags_flagwave2" else anim_speed = 80 -- 16 cycles - wave_sound = "flagwave3" + wave_sound = "pride_flags_flagwave3" end if self.object then @@ -114,10 +114,10 @@ minetest.register_node( "pride_flags:lower_mast", { description = "Flag Pole", drawtype = "mesh", paramtype = "light", - mesh = "mast_lower.obj", + mesh = "pride_flags_mast_lower.obj", paramtype2 = "facedir", groups = { cracky = 2, post = 1 }, - tiles = { "default_baremetal.png", "default_baremetal.png" }, + tiles = { "pride_flags_baremetal.png", "pride_flags_baremetal.png" }, groups = { cracky = 1, level = 2 }, --sounds = default.node_sound_metal_defaults( ), @@ -135,10 +135,10 @@ minetest.register_node( "pride_flags:upper_mast", { description = "Flag Pole", drawtype = "mesh", paramtype = "light", - mesh = "mast_upper.obj", + mesh = "pride_flags_mast_upper.obj", paramtype2 = "facedir", groups = { cracky = 2 }, - tiles = { "default_baremetal.png", "default_baremetal.png" }, + tiles = { "pride_flags_baremetal.png", "pride_flags_baremetal.png" }, groups = { cracky = 1, level = 2 }, --sounds = default.node_sound_metal_defaults( ), diff --git a/models/mast_lower.obj b/models/pride_flags_mast_lower.obj similarity index 100% rename from models/mast_lower.obj rename to models/pride_flags_mast_lower.obj diff --git a/models/mast_upper.obj b/models/pride_flags_mast_upper.obj similarity index 100% rename from models/mast_upper.obj rename to models/pride_flags_mast_upper.obj diff --git a/models/wavingflag.b3d b/models/pride_flags_wavingflag.b3d similarity index 100% rename from models/wavingflag.b3d rename to models/pride_flags_wavingflag.b3d diff --git a/sounds/flagwave1.ogg b/sounds/pride_flags_flagwave1.ogg similarity index 100% rename from sounds/flagwave1.ogg rename to sounds/pride_flags_flagwave1.ogg diff --git a/sounds/flagwave2.ogg b/sounds/pride_flags_flagwave2.ogg similarity index 100% rename from sounds/flagwave2.ogg rename to sounds/pride_flags_flagwave2.ogg diff --git a/sounds/flagwave3.ogg b/sounds/pride_flags_flagwave3.ogg similarity index 100% rename from sounds/flagwave3.ogg rename to sounds/pride_flags_flagwave3.ogg diff --git a/textures/default_baremetal.png b/textures/pride_flags_baremetal.png similarity index 100% rename from textures/default_baremetal.png rename to textures/pride_flags_baremetal.png From 42afe008274ad33afeb3524bc04ce00a56975a93 Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Sat, 2 Jul 2022 16:05:14 +0200 Subject: [PATCH 04/21] Some flag node improvements in inventory --- init.lua | 28 +++++++++++++++++++---- mod.conf | 1 + textures/pride_flags_pole_bottom_inv.png | Bin 0 -> 169 bytes textures/pride_flags_pole_top_inv.png | Bin 0 -> 5138 bytes 4 files changed, 24 insertions(+), 5 deletions(-) create mode 100644 textures/pride_flags_pole_bottom_inv.png create mode 100644 textures/pride_flags_pole_top_inv.png diff --git a/init.lua b/init.lua index fe94e8a..a46cef9 100644 --- a/init.lua +++ b/init.lua @@ -14,6 +14,13 @@ local rad_90 = pi / 2 local flag_list = { "rainbow", "lesbian", "bisexual", "transgender", "genderqueer", "nonbinary", "pansexual", "asexual" } +local S +if minetest.get_translator then + S = minetest.get_translator("pride_flags") +else + S = function(s) return s end +end + minetest.register_entity( "pride_flags:wavingflag", { initial_properties = { physical = false, @@ -110,16 +117,25 @@ minetest.register_entity( "pride_flags:wavingflag", { end, } ) +local metal_sounds +if minetest.get_modpath("default") ~= nil then + if default.node_sound_metal_defaults then + metal_sounds = default.node_sound_metal_defaults() + end +end + minetest.register_node( "pride_flags:lower_mast", { - description = "Flag Pole", + description = S("Flag Pole"), drawtype = "mesh", paramtype = "light", mesh = "pride_flags_mast_lower.obj", paramtype2 = "facedir", groups = { cracky = 2, post = 1 }, tiles = { "pride_flags_baremetal.png", "pride_flags_baremetal.png" }, - groups = { cracky = 1, level = 2 }, - --sounds = default.node_sound_metal_defaults( ), + wield_image = "pride_flags_pole_bottom_inv.png", + inventory_image = "pride_flags_pole_bottom_inv.png", + groups = { cracky = 1, level = 2 }, + sounds = metal_sounds, selection_box = { type = "fixed", @@ -132,15 +148,17 @@ minetest.register_node( "pride_flags:lower_mast", { } ) minetest.register_node( "pride_flags:upper_mast", { - description = "Flag Pole", + description = S("Flag Pole with Flag"), drawtype = "mesh", paramtype = "light", mesh = "pride_flags_mast_upper.obj", paramtype2 = "facedir", groups = { cracky = 2 }, tiles = { "pride_flags_baremetal.png", "pride_flags_baremetal.png" }, + wield_image = "pride_flags_pole_top_inv.png", + inventory_image = "pride_flags_pole_top_inv.png", groups = { cracky = 1, level = 2 }, - --sounds = default.node_sound_metal_defaults( ), + sounds = metal_sounds, selection_box = { type = "fixed", diff --git a/mod.conf b/mod.conf index 6a12099..d2b396f 100644 --- a/mod.conf +++ b/mod.conf @@ -2,4 +2,5 @@ name = pride_flags title = Pride Flags author = sorcerykid license = LGPL-3.0 +optional_depends = default diff --git a/textures/pride_flags_pole_bottom_inv.png b/textures/pride_flags_pole_bottom_inv.png new file mode 100644 index 0000000000000000000000000000000000000000..3a2189fc82cefd0e8a7bf2fb306d4085ab5dcb40 GIT binary patch literal 169 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61SBU+%rFB|Y$ZW{!9W@a@|Lkr1X6LHE{-7; zj8iUdWISTP;T*{Me*f&7&-B=)@H}vP75`DOAUf^c+#PTEJeWQ?luA1^r12Qs4NYyx z=aF&{dcfeIGN*0gF`I1v-Mk;pRh=_D@ct+JVTOYpThAPizopr0KIcLlmGw# literal 0 HcmV?d00001 diff --git a/textures/pride_flags_pole_top_inv.png b/textures/pride_flags_pole_top_inv.png new file mode 100644 index 0000000000000000000000000000000000000000..f0b8e8fb87d7f9267206853793f249af6eae10d3 GIT binary patch literal 5138 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 Date: Sat, 2 Jul 2022 16:06:21 +0200 Subject: [PATCH 05/21] Remove double groups definition in nodedefs --- init.lua | 2 -- 1 file changed, 2 deletions(-) diff --git a/init.lua b/init.lua index a46cef9..5b10bde 100644 --- a/init.lua +++ b/init.lua @@ -130,7 +130,6 @@ minetest.register_node( "pride_flags:lower_mast", { paramtype = "light", mesh = "pride_flags_mast_lower.obj", paramtype2 = "facedir", - groups = { cracky = 2, post = 1 }, tiles = { "pride_flags_baremetal.png", "pride_flags_baremetal.png" }, wield_image = "pride_flags_pole_bottom_inv.png", inventory_image = "pride_flags_pole_bottom_inv.png", @@ -153,7 +152,6 @@ minetest.register_node( "pride_flags:upper_mast", { paramtype = "light", mesh = "pride_flags_mast_upper.obj", paramtype2 = "facedir", - groups = { cracky = 2 }, tiles = { "pride_flags_baremetal.png", "pride_flags_baremetal.png" }, wield_image = "pride_flags_pole_top_inv.png", inventory_image = "pride_flags_pole_top_inv.png", From a729d0ce3b93a038736d5ee8b7e2ec7ecb917267 Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Sat, 2 Jul 2022 16:17:41 +0200 Subject: [PATCH 06/21] Fix crash if rightclick pole w/ missing entity --- init.lua | 60 ++++++++++++++++++++++++++++++++++---------------------- 1 file changed, 37 insertions(+), 23 deletions(-) diff --git a/init.lua b/init.lua index 5b10bde..0a21de9 100644 --- a/init.lua +++ b/init.lua @@ -146,6 +146,32 @@ minetest.register_node( "pride_flags:lower_mast", { }, } ) +local function spawn_flag( pos ) + local node_idx = minetest.hash_node_position( pos ) + local param2 = minetest.get_node( pos ).param2 + local facedir_to_pos = { + [0] = { x = 0, y = 0.6, z = -0.1 }, + [1] = { x = -0.1, y = 0.6, z = 0 }, + [2] = { x = 0, y = 0.6, z = 0.1 }, + [3] = { x = 0.1, y = 0.6, z = 0 }, + } + + local facedir_to_yaw = { + [0] = rad_90, + [1] = 0, + [2] = -rad_90, + [3] = rad_180, + } + local flag_pos = vector.add( pos, vector.multiply( facedir_to_pos[ param2 ], 1 ) ) + local obj = minetest.add_entity( flag_pos, "pride_flags:wavingflag" ) + + obj:get_luaentity( ).node_idx = node_idx + obj:set_yaw( facedir_to_yaw[ param2 ] - rad_180 ) + + active_flags[ node_idx ] = obj + return obj +end + minetest.register_node( "pride_flags:upper_mast", { description = S("Flag Pole with Flag"), drawtype = "mesh", @@ -171,33 +197,21 @@ minetest.register_node( "pride_flags:upper_mast", { local node_idx = minetest.hash_node_position( pos ) if minetest.check_player_privs( player:get_player_name( ), "server" ) then - active_flags[ node_idx ]:get_luaentity( ):reset_texture( ) + local aflag = active_flags[ node_idx ] + local flag + if aflag then + flag = aflag:get_luaentity( ) + end + if flag then + flag:reset_texture( ) + else + spawn_flag( pos ) + end end end, on_construct = function ( pos ) - local node_idx = minetest.hash_node_position( pos ) - local param2 = minetest.get_node( pos ).param2 - local facedir_to_pos = { - [0] = { x = 0, y = 0.6, z = -0.1 }, - [1] = { x = -0.1, y = 0.6, z = 0 }, - [2] = { x = 0, y = 0.6, z = 0.1 }, - [3] = { x = 0.1, y = 0.6, z = 0 }, - } - - local facedir_to_yaw = { - [0] = rad_90, - [1] = 0, - [2] = -rad_90, - [3] = rad_180, - } - local flag_pos = vector.add( pos, vector.multiply( facedir_to_pos[ param2 ], 1 ) ) - local obj = minetest.add_entity( flag_pos, "pride_flags:wavingflag" ) - - obj:get_luaentity( ).node_idx = node_idx - obj:set_yaw( facedir_to_yaw[ param2 ] - rad_180 ) - - active_flags[ node_idx ] = obj + spawn_flag ( pos ) end, on_destruct = function ( pos ) From 52097be0841a41983e9f976fa3d9542afe7dc183 Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Sat, 2 Jul 2022 16:36:39 +0200 Subject: [PATCH 07/21] Add screwdriver support --- init.lua | 40 +++++++++++++++++++++++++++++++++------- mod.conf | 2 +- 2 files changed, 34 insertions(+), 8 deletions(-) diff --git a/init.lua b/init.lua index 0a21de9..3e91d4f 100644 --- a/init.lua +++ b/init.lua @@ -144,8 +144,29 @@ minetest.register_node( "pride_flags:lower_mast", { type = "fixed", fixed = { { -3/32, -1/2, -3/32, 3/32, 1/2, 3/32 } }, }, + + on_rotate = function(pos, node, user, mode, new_param2) + if mode == screwdriver.ROTATE_AXIS then + return false + end + end, } ) +local function rotate_flag_by_param2( flag, param2 ) + local facedir_to_yaw = { + [0] = rad_90, + [1] = 0, + [2] = -rad_90, + [3] = rad_180, + } + local baseyaw = facedir_to_yaw[ param2 ] + if not baseyaw then + minetest.log("warning", "[pride_flags] Unsupported flag pole node param2: "..tostring(param2)) + return + end + flag:set_yaw( baseyaw - rad_180 ) +end + local function spawn_flag( pos ) local node_idx = minetest.hash_node_position( pos ) local param2 = minetest.get_node( pos ).param2 @@ -156,17 +177,11 @@ local function spawn_flag( pos ) [3] = { x = 0.1, y = 0.6, z = 0 }, } - local facedir_to_yaw = { - [0] = rad_90, - [1] = 0, - [2] = -rad_90, - [3] = rad_180, - } local flag_pos = vector.add( pos, vector.multiply( facedir_to_pos[ param2 ], 1 ) ) local obj = minetest.add_entity( flag_pos, "pride_flags:wavingflag" ) obj:get_luaentity( ).node_idx = node_idx - obj:set_yaw( facedir_to_yaw[ param2 ] - rad_180 ) + rotate_flag_by_param2( obj, param2 ) active_flags[ node_idx ] = obj return obj @@ -220,4 +235,15 @@ minetest.register_node( "pride_flags:upper_mast", { active_flags[ node_idx ]:remove( ) end end, + + on_rotate = function(pos, node, user, mode, new_param2) + if mode == screwdriver.ROTATE_AXIS then + return false + end + local node_idx = minetest.hash_node_position( pos ) + local aflag = active_flags[ node_idx ] + if aflag then + rotate_flag_by_param2( aflag, new_param2 ) + end + end, } ) diff --git a/mod.conf b/mod.conf index d2b396f..01122a5 100644 --- a/mod.conf +++ b/mod.conf @@ -2,5 +2,5 @@ name = pride_flags title = Pride Flags author = sorcerykid license = LGPL-3.0 -optional_depends = default +optional_depends = default, screwdriver From 201db6bd8a17c42b0115f11f6a14935f659deed0 Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Sat, 2 Jul 2022 16:39:53 +0200 Subject: [PATCH 08/21] Fix deprecation warning for get2d call --- init.lua | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/init.lua b/init.lua index 3e91d4f..d7dfb0e 100644 --- a/init.lua +++ b/init.lua @@ -6,6 +6,13 @@ -------------------------------------------------------- local wind_noise = PerlinNoise( 204, 1, 0, 500 ) +-- Check whether the new `get_2d` Perlin function is available, +-- otherwise use `get2d`. Needed to suppress deprecation +-- warning in newer Minetest versions. +local old_get2d = true +if wind_noise.get_2d then + old_get2d = false +end local active_flags = { } local pi = math.pi @@ -71,7 +78,14 @@ minetest.register_entity( "pride_flags:wavingflag", { end, reset_animation = function ( self, start_frame ) - local cur_wind = wind_noise:get2d( { x = os.time( ) % 65535, y = 0 } ) * 30 + 30 + local coords = { x = os.time( ) % 65535, y = 0 } + local cur_wind + if old_get2d then + cur_wind = wind_noise:get2d(coords) + else + cur_wind = wind_noise:get_2d(coords) + end + cur_wind = cur_wind * 30 + 30 minetest.log("verbose", "[pride_flags] Current wind: " .. cur_wind) local anim_speed local wave_sound From 71853506ef6fc9b47dc39bd252423a5f24cb4187 Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Sat, 2 Jul 2022 16:49:27 +0200 Subject: [PATCH 09/21] Cycle flags backwards when punching --- README.txt | 5 +++-- init.lua | 46 +++++++++++++++++++++++++++++++++------------- 2 files changed, 36 insertions(+), 15 deletions(-) diff --git a/README.txt b/README.txt index a3915c7..e86ed25 100644 --- a/README.txt +++ b/README.txt @@ -9,8 +9,9 @@ conspicuous location, such as atop a building or along a promenade. /giveme pride_flags:mast_lower /giveme pride_flags:mast_upper -By default, a rainbow pride flag will appear when the upper mast is placed. Right-click -the node to select a different flag (this requires the "server" privilege). +Initially, the rainbow pride flag will appear when the upper mast is placed. +Right-click or punch the node to select a different flag +(this requires the "server" privilege). Repository diff --git a/init.lua b/init.lua index d7dfb0e..3a91747 100644 --- a/init.lua +++ b/init.lua @@ -114,8 +114,16 @@ minetest.register_entity( "pride_flags:wavingflag", { reset_texture = function ( self, flag_idx ) if not flag_idx then + -- next flag self.flag_idx = self.flag_idx % #flag_list + 1 -- this automatically increments + elseif flag_idx == -1 then + -- previous flag + self.flag_idx = self.flag_idx - 1 + if self.flag_idx < 1 then + self.flag_idx = #flag_list + end else + -- set flag directly self.flag_idx = flag_idx end @@ -201,6 +209,27 @@ local function spawn_flag( pos ) return obj end +local function cycle_flag( pos, player, cycle_backwards ) + local node_idx = minetest.hash_node_position( pos ) + + if minetest.check_player_privs( player:get_player_name( ), "server" ) then + local aflag = active_flags[ node_idx ] + local flag + if aflag then + flag = aflag:get_luaentity( ) + end + if flag then + if cycle_backwards then + flag:reset_texture( -1 ) + else + flag:reset_texture( ) + end + else + spawn_flag( pos ) + end + end +end + minetest.register_node( "pride_flags:upper_mast", { description = S("Flag Pole with Flag"), drawtype = "mesh", @@ -223,20 +252,11 @@ minetest.register_node( "pride_flags:upper_mast", { }, on_rightclick = function ( pos, node, player ) - local node_idx = minetest.hash_node_position( pos ) + cycle_flag( pos, player ) + end, - if minetest.check_player_privs( player:get_player_name( ), "server" ) then - local aflag = active_flags[ node_idx ] - local flag - if aflag then - flag = aflag:get_luaentity( ) - end - if flag then - flag:reset_texture( ) - else - spawn_flag( pos ) - end - end + on_punch = function ( pos, node, player ) + cycle_flag( pos, player, -1 ) end, on_construct = function ( pos ) From 858610b8eedd51051bf464ab7e43c0ac91150c28 Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Sat, 2 Jul 2022 17:37:59 +0200 Subject: [PATCH 10/21] Save/load flag index in flag pole node meta Needed when flag entity must be respawned --- init.lua | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/init.lua b/init.lua index 3a91747..599c7d3 100644 --- a/init.lua +++ b/init.lua @@ -127,8 +127,14 @@ minetest.register_entity( "pride_flags:wavingflag", { self.flag_idx = flag_idx end + -- Fallback flag + if not flag_list[ self.flag_idx ] then + self.flag_idx = 1 + end + local texture = string.format( "prideflag_%s.png", flag_list[ self.flag_idx ] ) self.object:set_properties( { textures = { texture } } ) + return self.flag_idx end, get_staticdata = function ( self ) @@ -219,13 +225,21 @@ local function cycle_flag( pos, player, cycle_backwards ) flag = aflag:get_luaentity( ) end if flag then + local flag_idx if cycle_backwards then - flag:reset_texture( -1 ) + flag_idx = flag:reset_texture( -1 ) else - flag:reset_texture( ) + flag_idx = flag:reset_texture( ) end + local meta = minetest.get_meta( pos ) + meta:set_int("flag_idx", flag_idx) else - spawn_flag( pos ) + flag = spawn_flag( pos ) + if flag and flag:get_luaentity() then + local meta = minetest.get_meta( pos ) + local flag_idx = meta:get_int("flag_idx") + flag:get_luaentity():reset_texture( flag_idx ) + end end end end @@ -260,7 +274,11 @@ minetest.register_node( "pride_flags:upper_mast", { end, on_construct = function ( pos ) - spawn_flag ( pos ) + local flag = spawn_flag ( pos ) + if flag and flag:get_luaentity() then + local meta = minetest.get_meta( pos ) + meta:set_int("flag_idx", flag:get_luaentity().flag_idx) + end end, on_destruct = function ( pos ) From 901722ca97ed41f8fd87e1f95bbdbd20f844a9da Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Sun, 3 Jul 2022 00:25:34 +0200 Subject: [PATCH 11/21] Fix rotation misplacing flag --- init.lua | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/init.lua b/init.lua index 599c7d3..8c81bf5 100644 --- a/init.lua +++ b/init.lua @@ -180,6 +180,16 @@ minetest.register_node( "pride_flags:lower_mast", { end, } ) +local function get_flag_pos( pos, param2 ) + local facedir_to_pos = { + [0] = { x = 0, y = 0.6, z = -0.1 }, + [1] = { x = -0.1, y = 0.6, z = 0 }, + [2] = { x = 0, y = 0.6, z = 0.1 }, + [3] = { x = 0.1, y = 0.6, z = 0 }, + } + return vector.add( pos, vector.multiply( facedir_to_pos[ param2 ], 1 ) ) +end + local function rotate_flag_by_param2( flag, param2 ) local facedir_to_yaw = { [0] = rad_90, @@ -198,14 +208,8 @@ end local function spawn_flag( pos ) local node_idx = minetest.hash_node_position( pos ) local param2 = minetest.get_node( pos ).param2 - local facedir_to_pos = { - [0] = { x = 0, y = 0.6, z = -0.1 }, - [1] = { x = -0.1, y = 0.6, z = 0 }, - [2] = { x = 0, y = 0.6, z = 0.1 }, - [3] = { x = 0.1, y = 0.6, z = 0 }, - } - local flag_pos = vector.add( pos, vector.multiply( facedir_to_pos[ param2 ], 1 ) ) + local flag_pos = get_flag_pos( pos, param2 ) local obj = minetest.add_entity( flag_pos, "pride_flags:wavingflag" ) obj:get_luaentity( ).node_idx = node_idx @@ -295,7 +299,12 @@ minetest.register_node( "pride_flags:upper_mast", { local node_idx = minetest.hash_node_position( pos ) local aflag = active_flags[ node_idx ] if aflag then + local lua = aflag:get_luaentity( ) + local flag_pos_idx = lua.node_idx + local flag_pos = minetest.get_position_from_hash( flag_pos_idx ) + flag_pos = get_flag_pos( flag_pos, new_param2 ) rotate_flag_by_param2( aflag, new_param2 ) + aflag:set_pos( flag_pos ) end end, } ) From 5ba46824ad16b3ad4cdaa5267516fab5d1b1c6e1 Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Sun, 3 Jul 2022 00:36:39 +0200 Subject: [PATCH 12/21] Prevent spawning double flags --- init.lua | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/init.lua b/init.lua index 8c81bf5..5f1f500 100644 --- a/init.lua +++ b/init.lua @@ -60,6 +60,20 @@ minetest.register_entity( "pride_flags:wavingflag", { else self.flag_idx = 1 end + + -- Delete entity if there is already one for this pos + local objs = minetest.get_objects_inside_radius( self.object:get_pos(), 0.5 ) + for o=1, #objs do + local obj = objs[o] + local lua = obj:get_luaentity( ) + local name = lua.name + if self ~= lua and name == "pride_flags:wavingflag" then + if lua.node_idx == self.node_idx then + self.object:remove( ) + return + end + end + end end, on_deactivate = function ( self ) @@ -211,6 +225,9 @@ local function spawn_flag( pos ) local flag_pos = get_flag_pos( pos, param2 ) local obj = minetest.add_entity( flag_pos, "pride_flags:wavingflag" ) + if not obj or not obj:get_luaentity( ) then + return + end obj:get_luaentity( ).node_idx = node_idx rotate_flag_by_param2( obj, param2 ) From f4964faacabb1a1a0182f8d2801f49e58d8a381d Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Sun, 3 Jul 2022 00:44:23 +0200 Subject: [PATCH 13/21] Respawn flag entities on loading chunk --- init.lua | 40 ++++++++++++++++++++++++++++++++++------ 1 file changed, 34 insertions(+), 6 deletions(-) diff --git a/init.lua b/init.lua index 5f1f500..c3e3ee8 100644 --- a/init.lua +++ b/init.lua @@ -54,6 +54,13 @@ minetest.register_entity( "pride_flags:wavingflag", { self.object:remove( ) return end + + local aflag = active_flags[ self.node_idx ] + if aflag then + minetest.log("error", "stop_a") + return + end + self:reset_texture( self.flag_idx ) active_flags[ self.node_idx ] = self.object @@ -236,6 +243,15 @@ local function spawn_flag( pos ) return obj end +local function spawn_flag_and_set_meta( pos ) + local flag = spawn_flag( pos ) + if flag and flag:get_luaentity() then + local meta = minetest.get_meta( pos ) + local flag_idx = meta:get_int("flag_idx") + flag:get_luaentity():reset_texture( flag_idx ) + end +end + local function cycle_flag( pos, player, cycle_backwards ) local node_idx = minetest.hash_node_position( pos ) @@ -255,12 +271,7 @@ local function cycle_flag( pos, player, cycle_backwards ) local meta = minetest.get_meta( pos ) meta:set_int("flag_idx", flag_idx) else - flag = spawn_flag( pos ) - if flag and flag:get_luaentity() then - local meta = minetest.get_meta( pos ) - local flag_idx = meta:get_int("flag_idx") - flag:get_luaentity():reset_texture( flag_idx ) - end + spawn_flag_and_set_meta( pos ) end end end @@ -325,3 +336,20 @@ minetest.register_node( "pride_flags:upper_mast", { end end, } ) + +minetest.register_lbm({ + name = "pride_flags:respawn_flags", + label = "Respawn flags", + nodenames = {"pride_flags:upper_mast"}, + run_at_every_load = true, + action = function(pos, node) + local node_idx = minetest.hash_node_position( pos ) + local aflag = active_flags[ node_idx ] + if aflag then + minetest.log("error", "stop") + return + end + spawn_flag_and_set_meta( pos ) + minetest.log("error", "sp:"..minetest.pos_to_string(pos)) + end +}) From ae0929a6dd2b333b28d1018c6abe4cd450bec073 Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Sun, 3 Jul 2022 00:48:54 +0200 Subject: [PATCH 14/21] Respawn flags on loading chunk, part 2 --- init.lua | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/init.lua b/init.lua index c3e3ee8..7a6f41f 100644 --- a/init.lua +++ b/init.lua @@ -55,12 +55,6 @@ minetest.register_entity( "pride_flags:wavingflag", { return end - local aflag = active_flags[ self.node_idx ] - if aflag then - minetest.log("error", "stop_a") - return - end - self:reset_texture( self.flag_idx ) active_flags[ self.node_idx ] = self.object @@ -243,13 +237,14 @@ local function spawn_flag( pos ) return obj end -local function spawn_flag_and_set_meta( pos ) +local function spawn_flag_and_set_texture( pos ) local flag = spawn_flag( pos ) if flag and flag:get_luaentity() then local meta = minetest.get_meta( pos ) local flag_idx = meta:get_int("flag_idx") flag:get_luaentity():reset_texture( flag_idx ) end + return flag end local function cycle_flag( pos, player, cycle_backwards ) @@ -271,7 +266,7 @@ local function cycle_flag( pos, player, cycle_backwards ) local meta = minetest.get_meta( pos ) meta:set_int("flag_idx", flag_idx) else - spawn_flag_and_set_meta( pos ) + spawn_flag_and_set_texture( pos ) end end end @@ -328,6 +323,15 @@ minetest.register_node( "pride_flags:upper_mast", { local aflag = active_flags[ node_idx ] if aflag then local lua = aflag:get_luaentity( ) + if not lua then + aflag = spawn_flag_and_set_texture( pos ) + if aflag then + lua = aflag:get_luaentity() + if not lua then + return + end + end + end local flag_pos_idx = lua.node_idx local flag_pos = minetest.get_position_from_hash( flag_pos_idx ) flag_pos = get_flag_pos( flag_pos, new_param2 ) @@ -346,10 +350,8 @@ minetest.register_lbm({ local node_idx = minetest.hash_node_position( pos ) local aflag = active_flags[ node_idx ] if aflag then - minetest.log("error", "stop") return end - spawn_flag_and_set_meta( pos ) - minetest.log("error", "sp:"..minetest.pos_to_string(pos)) + spawn_flag_and_set_texture( pos ) end }) From 88ce6844ffd23cec78a521a1aa6d9a3826f3cd12 Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Sun, 3 Jul 2022 01:42:08 +0200 Subject: [PATCH 15/21] Redo anim handling and fix anim jumps --- init.lua | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/init.lua b/init.lua index 7a6f41f..b8236e2 100644 --- a/init.lua +++ b/init.lua @@ -42,7 +42,7 @@ minetest.register_entity( "pride_flags:wavingflag", { }, on_activate = function ( self, staticdata, dtime ) - self:reset_animation( math.random( 1, 50 ) ) -- random starting frame to desynchronize multiple flags + self:reset_animation( true ) self.object:set_armor_groups( { immortal = 1 } ) if staticdata ~= "" then @@ -67,8 +67,7 @@ minetest.register_entity( "pride_flags:wavingflag", { for o=1, #objs do local obj = objs[o] local lua = obj:get_luaentity( ) - local name = lua.name - if self ~= lua and name == "pride_flags:wavingflag" then + if lua and self ~= lua and lua.name == "pride_flags:wavingflag" then if lua.node_idx == self.node_idx then self.object:remove( ) return @@ -88,11 +87,11 @@ minetest.register_entity( "pride_flags:wavingflag", { if self.anim_timer <= 0 then minetest.sound_stop( self.sound_id ) - self:reset_animation( 1 ) + self:reset_animation( ) end end, - reset_animation = function ( self, start_frame ) + reset_animation = function ( self, initial ) local coords = { x = os.time( ) % 65535, y = 0 } local cur_wind if old_get2d then @@ -105,6 +104,9 @@ minetest.register_entity( "pride_flags:wavingflag", { local anim_speed local wave_sound + cur_wind = math.random(0, 50) + cur_wind = 30 + if cur_wind < 10 then anim_speed = 10 -- 2 cycle wave_sound = "pride_flags_flagwave1" @@ -118,13 +120,19 @@ minetest.register_entity( "pride_flags:wavingflag", { anim_speed = 80 -- 16 cycles wave_sound = "pride_flags_flagwave3" end + -- slightly anim_speed change to desyncronize flag waving + anim_speed = anim_speed + math.random(0, 200) * 0.01 if self.object then - self.object:set_animation( { x = start_frame, y = 575 }, anim_speed, 0, true ) + if initial or (not self.object.set_animation_frame_speed) then + self.object:set_animation( { x = 1, y = 575 }, anim_speed, 0, true ) + else + self.object:set_animation_frame_speed(anim_speed) + end self.sound_id = minetest.sound_play( wave_sound, { object = self.object, gain = 1.0, loop = true } ) end - self.anim_timer = ( 576 - start_frame ) / 5 -- default to 115 seconds to reset animation + self.anim_timer = 115 + math.random(-10, 10) -- time to reset animation end, reset_texture = function ( self, flag_idx ) From 1fe38606b4fbfc74d871fa699e8d8e4eafdbdb9a Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Mon, 4 Jul 2022 18:13:35 +0200 Subject: [PATCH 16/21] Add German translation --- locale/pride_flags.de.tr | 3 +++ locale/template.txt | 3 +++ 2 files changed, 6 insertions(+) create mode 100644 locale/pride_flags.de.tr create mode 100644 locale/template.txt diff --git a/locale/pride_flags.de.tr b/locale/pride_flags.de.tr new file mode 100644 index 0000000..8d79265 --- /dev/null +++ b/locale/pride_flags.de.tr @@ -0,0 +1,3 @@ +# textdomain:pride_flags +Flag Pole=Flaggenmast +Flag Pole with Flag=Flaggenmast mit Flagge diff --git a/locale/template.txt b/locale/template.txt new file mode 100644 index 0000000..7f49cdc --- /dev/null +++ b/locale/template.txt @@ -0,0 +1,3 @@ +# textdomain:pride_flags +Flag Pole= +Flag Pole with Flag= From 889744fc7a33b9ed1c8237174a8ac3c2b09f2679 Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Mon, 4 Jul 2022 18:22:48 +0200 Subject: [PATCH 17/21] Add crafts --- init.lua | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/init.lua b/init.lua index b8236e2..a10e945 100644 --- a/init.lua +++ b/init.lua @@ -363,3 +363,21 @@ minetest.register_lbm({ spawn_flag_and_set_texture( pos ) end }) + +if minetest.get_modpath("default") then + minetest.register_craft({ + output = "pride_flags:lower_mast 6", + recipe = { + {"default:steel_ingot"}, + {"default:steel_ingot"}, + {"default:steel_ingot"}, + }, + }) +end +minetest.register_craft({ + output = "pride_flags:upper_mast", + recipe = { + {"pride_flags:lower_mast", "group:wool", "group:wool"}, + {"pride_flags:lower_mast", "group:wool", "group:wool"}, + }, +}) From 7698ceebd00bcc06ec819238bc2544e749599d3c Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Mon, 4 Jul 2022 18:33:06 +0200 Subject: [PATCH 18/21] No longer need server priv to change flag, check protection instead --- README.txt | 3 +-- init.lua | 37 +++++++++++++++++++++---------------- 2 files changed, 22 insertions(+), 18 deletions(-) diff --git a/README.txt b/README.txt index e86ed25..fd2b5ed 100644 --- a/README.txt +++ b/README.txt @@ -10,8 +10,7 @@ conspicuous location, such as atop a building or along a promenade. /giveme pride_flags:mast_upper Initially, the rainbow pride flag will appear when the upper mast is placed. -Right-click or punch the node to select a different flag -(this requires the "server" privilege). +Right-click or punch the node to select a different flag. Repository diff --git a/init.lua b/init.lua index a10e945..fb15ee7 100644 --- a/init.lua +++ b/init.lua @@ -256,26 +256,31 @@ local function spawn_flag_and_set_texture( pos ) end local function cycle_flag( pos, player, cycle_backwards ) + local pname = player:get_player_name( ) + if minetest.is_protected( pos, pname ) and not + minetest.check_player_privs( pname, "protection_bypass") then + minetest.register_protection_violation( pos, pname ) + return + end + local node_idx = minetest.hash_node_position( pos ) - if minetest.check_player_privs( player:get_player_name( ), "server" ) then - local aflag = active_flags[ node_idx ] - local flag - if aflag then - flag = aflag:get_luaentity( ) - end - if flag then - local flag_idx - if cycle_backwards then - flag_idx = flag:reset_texture( -1 ) - else - flag_idx = flag:reset_texture( ) - end - local meta = minetest.get_meta( pos ) - meta:set_int("flag_idx", flag_idx) + local aflag = active_flags[ node_idx ] + local flag + if aflag then + flag = aflag:get_luaentity( ) + end + if flag then + local flag_idx + if cycle_backwards then + flag_idx = flag:reset_texture( -1 ) else - spawn_flag_and_set_texture( pos ) + flag_idx = flag:reset_texture( ) end + local meta = minetest.get_meta( pos ) + meta:set_int("flag_idx", flag_idx) + else + spawn_flag_and_set_texture( pos ) end end From a570ed7c36c50db03821c280c99ae88198b6f32f Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Mon, 4 Jul 2022 18:46:02 +0200 Subject: [PATCH 19/21] Reduce entity collisionbox size to 0 So the flagpole is easier to point to --- init.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/init.lua b/init.lua index fb15ee7..5a9d5c9 100644 --- a/init.lua +++ b/init.lua @@ -33,7 +33,7 @@ minetest.register_entity( "pride_flags:wavingflag", { physical = false, visual = "mesh", visual_size = { x = 8.5, y = 8.5 }, - collisionbox = { -0.1, -0.85, -0.1, 0.1, 0.85, 0.1 }, + collisionbox = { 0, 0, 0, 0, 0, 0 }, backface_culling = false, pointable = false, mesh = "pride_flags_wavingflag.b3d", From cff6a2f9c1b1c72999c227c3cc30dedba9b50db3 Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Mon, 4 Jul 2022 18:48:13 +0200 Subject: [PATCH 20/21] Make flag poles easier to dig --- init.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/init.lua b/init.lua index 5a9d5c9..3939470 100644 --- a/init.lua +++ b/init.lua @@ -184,7 +184,7 @@ minetest.register_node( "pride_flags:lower_mast", { tiles = { "pride_flags_baremetal.png", "pride_flags_baremetal.png" }, wield_image = "pride_flags_pole_bottom_inv.png", inventory_image = "pride_flags_pole_bottom_inv.png", - groups = { cracky = 1, level = 2 }, + groups = { cracky = 2 }, sounds = metal_sounds, selection_box = { @@ -293,7 +293,7 @@ minetest.register_node( "pride_flags:upper_mast", { tiles = { "pride_flags_baremetal.png", "pride_flags_baremetal.png" }, wield_image = "pride_flags_pole_top_inv.png", inventory_image = "pride_flags_pole_top_inv.png", - groups = { cracky = 1, level = 2 }, + groups = { cracky = 2 }, sounds = metal_sounds, selection_box = { From 0bf02d3245ccd6b90a150d0f55b35057ece41f41 Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Mon, 4 Jul 2022 19:30:54 +0200 Subject: [PATCH 21/21] Only start sound once per flag --- init.lua | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/init.lua b/init.lua index 3939470..a80faa0 100644 --- a/init.lua +++ b/init.lua @@ -86,7 +86,6 @@ minetest.register_entity( "pride_flags:wavingflag", { self.anim_timer = self.anim_timer - dtime if self.anim_timer <= 0 then - minetest.sound_stop( self.sound_id ) self:reset_animation( ) end end, @@ -129,6 +128,8 @@ minetest.register_entity( "pride_flags:wavingflag", { else self.object:set_animation_frame_speed(anim_speed) end + end + if not self.sound_id then self.sound_id = minetest.sound_play( wave_sound, { object = self.object, gain = 1.0, loop = true } ) end