From 83ec874634a79f58c1907ea6e3ab7dccf6de0f86 Mon Sep 17 00:00:00 2001 From: Aaron Suen Date: Sat, 5 Nov 2022 11:50:26 -0400 Subject: [PATCH] Clear up some todo items --- TODO | 16 +++------------- szutil_cinecam/init.lua | 35 ++++++++++++++++++++++++----------- 2 files changed, 27 insertions(+), 24 deletions(-) diff --git a/TODO b/TODO index 061a735..9046821 100644 --- a/TODO +++ b/TODO @@ -1,24 +1,14 @@ ------------------------------------------------------------------------ - szutil_cinecam - - Priv and/or API to hide player from rotation - - Add slight facedir bias (smaller than chase-velocity bias) - - Need ability to control player cycling - - Priv just lets you configure match list - - Match list applies rules for matching players - - * wildcard - - !filter to exclude players matching filter - - admin priv to externally control filters + - optional sprite visual for camera position to show other players? + - use entity attachments instead of relying on fly priv + - clear darken/vignette HUDs if player is removed from cycling - configurability via settings w/ live updates - remote control of FOV? - settingtypes.txt for all mods -- Player cleanup mod - - Remove players after N days absent - - Only if no new privs granted - - Configurable set of ignored privs - - Delayed privileges mod - Countdown modes: - Always-running countdown diff --git a/szutil_cinecam/init.lua b/szutil_cinecam/init.lua index 472b2e3..15f77b5 100644 --- a/szutil_cinecam/init.lua +++ b/szutil_cinecam/init.lua @@ -1,6 +1,6 @@ -- LUALOCALS < --------------------------------------------------------- -local ipairs, math, minetest, pairs, tonumber, type - = ipairs, math, minetest, pairs, tonumber, type +local ipairs, math, minetest, pairs, rawget, rawset, tonumber, type + = ipairs, math, minetest, pairs, rawget, rawset, tonumber, type local math_atan2, math_ceil, math_cos, math_pi, math_random, math_sin, math_sqrt = math.atan2, math.ceil, math.cos, math.pi, math.random, math.sin, @@ -9,6 +9,9 @@ local math_atan2, math_ceil, math_cos, math_pi, math_random, math_sin, local modname = minetest.get_current_modname() +local api = rawget(_G, modname) or {} +rawset(_G, modname, api) + local defaults = { cycletime = 20, -- time between cycles hudtime = 4, -- duration to display HUD @@ -227,6 +230,19 @@ local function camdummy(player, data, dtime) data.dummycam = config.cycletime end +function api.get_watchable_player_names() + local names = {} + for _, p in ipairs(minetest.get_connected_players()) do + local n = p:get_player_name() + local props = p:get_properties() + local vs = props and props.visual_size + if vs and vs.x > 0 and vs.y > 0 then + names[n] = true + end + end + return names +end + local function camcheck(player, dtime) local data = getdata(player) @@ -268,15 +284,12 @@ local function camcheck(player, dtime) if not (data.queue and #data.queue > 0) then local q = {} local pname = player:get_player_name() - for _, p in ipairs(minetest.get_connected_players()) do - local n = p:get_player_name() - if n ~= pname then - local props = p:get_properties() - local vs = props and props.visual_size - if vs and vs.x > 0 and vs.y > 0 then - q[#q + 1] = n - end - end + for n in pairs(api.get_watchable_player_names()) do + if n ~= pname then q[#q + 1] = n end + end + for i = #q, 2, -1 do + local j = math_random(1, i) + q[i], q[j] = q[j], q[i] end if #q < 1 then return camdummy(player, data, dtime) end data.queue = q