From 75993bf9336261e24785f6bc70bd09121149bbe4 Mon Sep 17 00:00:00 2001 From: thedax Date: Wed, 25 Jun 2025 15:21:09 -0400 Subject: [PATCH] Update to Lua 5.4, adjust scripts accordingly (#64) --- Cargo.toml | 2 +- resources/scripts/Global.lua | 10 ++++++++++ resources/scripts/commands/debug/ChangeTerritory.lua | 2 +- resources/scripts/commands/debug/Festival.lua | 5 ++--- resources/scripts/commands/debug/Nudge.lua | 2 +- resources/scripts/commands/debug/SetSpeed.lua | 2 +- .../scripts/commands/debug/ToggleInvisibility.lua | 2 -- resources/scripts/commands/debug/ToggleWireframe.lua | 2 -- resources/scripts/commands/debug/Unlock.lua | 2 +- resources/scripts/commands/debug/UnlockAetheryte.lua | 2 +- resources/scripts/events/common/GenericAetheryte.lua | 2 +- 11 files changed, 19 insertions(+), 14 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index c0e4fd5..201465e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -89,7 +89,7 @@ rusqlite = { version = "0.36", features = ["bundled"], default-features = false bitflags = { version = "2.9", default-features = false } # For server-side scripting -mlua = { version = "0.10", features = ["lua51", "vendored", "send", "async", "serialize"], default-features = false } +mlua = { version = "0.10", features = ["lua54", "vendored", "send", "async", "serialize"], default-features = false } # For character backup decompression zip = { version = "4.1", features = ["deflate", "lzma", "bzip2"], default-features = false } diff --git a/resources/scripts/Global.lua b/resources/scripts/Global.lua index 08897d3..e7dc604 100644 --- a/resources/scripts/Global.lua +++ b/resources/scripts/Global.lua @@ -14,6 +14,16 @@ function split(input, separator) return t end +function getTableSize(tbl) + local count = 0 + + for _, _ in pairs(tbl) do + count = count + 1 + end + + return count +end + -- Constants GM_RANK_NORMALUSER = 0 GM_RANK_GAMEMASTER = 1 diff --git a/resources/scripts/commands/debug/ChangeTerritory.lua b/resources/scripts/commands/debug/ChangeTerritory.lua index b2b0135..aa67ee6 100644 --- a/resources/scripts/commands/debug/ChangeTerritory.lua +++ b/resources/scripts/commands/debug/ChangeTerritory.lua @@ -2,7 +2,7 @@ required_rank = GM_RANK_DEBUG function onCommand(args, player) local parts = split(args) - local argc = table.getn(parts) + local argc = #parts local sender = "[teri] " local usage = "\nThis command moves the user to a new zone/territory.\nUsage: !teri " diff --git a/resources/scripts/commands/debug/Festival.lua b/resources/scripts/commands/debug/Festival.lua index 6969884..81ad803 100644 --- a/resources/scripts/commands/debug/Festival.lua +++ b/resources/scripts/commands/debug/Festival.lua @@ -4,7 +4,7 @@ required_rank = GM_RANK_DEBUG function onCommand(args, player) local parts = split(args) - local argc = table.getn(parts) + local argc = #parts local usage = "\nUsage: !festival " local sender = "[festival] " @@ -14,8 +14,7 @@ function onCommand(args, player) local id4 = tonumber(parts[4]) if not id1 then - player:send_message(sender.."At least one festival must be specified (for now, until the server has support for commands with no args)."..usage) - return + id1 = 0 end if not id2 then diff --git a/resources/scripts/commands/debug/Nudge.lua b/resources/scripts/commands/debug/Nudge.lua index 6a63a06..8f93093 100644 --- a/resources/scripts/commands/debug/Nudge.lua +++ b/resources/scripts/commands/debug/Nudge.lua @@ -8,7 +8,7 @@ end function onCommand(args, player) local parts = split(args) - local argc = table.getn(parts) + local argc = #parts local pos = player.position local angle = player.rotation + (math.pi / 2) local distance = 5 diff --git a/resources/scripts/commands/debug/SetSpeed.lua b/resources/scripts/commands/debug/SetSpeed.lua index 6ddee89..cf22734 100644 --- a/resources/scripts/commands/debug/SetSpeed.lua +++ b/resources/scripts/commands/debug/SetSpeed.lua @@ -2,7 +2,7 @@ required_rank = GM_RANK_DEBUG function onCommand(args, player) local parts = split(args) - local argc = table.getn(parts) + local argc = #parts local sender = "[setspeed] " local usage = "\nThis command sets the user's speed to a desired multiplier.\nUsage: !setspeed " local SPEED_MAX = 10 -- Arbitrary, but it's more or less unplayable even at this amount diff --git a/resources/scripts/commands/debug/ToggleInvisibility.lua b/resources/scripts/commands/debug/ToggleInvisibility.lua index 3277f4c..7beb877 100644 --- a/resources/scripts/commands/debug/ToggleInvisibility.lua +++ b/resources/scripts/commands/debug/ToggleInvisibility.lua @@ -1,8 +1,6 @@ required_rank = GM_RANK_DEBUG function onCommand(args, player) - local parts = split(args) - local argc = table.getn(parts) local sender = "[invis] " local usage = "\nThis command makes the user invisible to all other actors." diff --git a/resources/scripts/commands/debug/ToggleWireframe.lua b/resources/scripts/commands/debug/ToggleWireframe.lua index 978c6c4..4a89da5 100644 --- a/resources/scripts/commands/debug/ToggleWireframe.lua +++ b/resources/scripts/commands/debug/ToggleWireframe.lua @@ -1,8 +1,6 @@ required_rank = GM_RANK_DEBUG function onCommand(args, player) - local parts = split(args) - local argc = table.getn(parts) local sender = "[wireframe] " local usage = "\nThis command allows the user to view the world in wireframe mode." diff --git a/resources/scripts/commands/debug/Unlock.lua b/resources/scripts/commands/debug/Unlock.lua index 1768730..dfc2d5b 100644 --- a/resources/scripts/commands/debug/Unlock.lua +++ b/resources/scripts/commands/debug/Unlock.lua @@ -2,7 +2,7 @@ required_rank = GM_RANK_DEBUG function onCommand(args, player) local parts = split(args) - local argc = table.getn(parts) + local argc = #parts local sender = "[unlockaction] " local usage = "\nThis command teaches the user an action, emote, etc.\nUsage: !useaction " diff --git a/resources/scripts/commands/debug/UnlockAetheryte.lua b/resources/scripts/commands/debug/UnlockAetheryte.lua index 9106231..c05567c 100644 --- a/resources/scripts/commands/debug/UnlockAetheryte.lua +++ b/resources/scripts/commands/debug/UnlockAetheryte.lua @@ -2,7 +2,7 @@ required_rank = GM_RANK_DEBUG function onCommand(args, player) local parts = split(args) - local argc = table.getn(parts) + local argc = #parts local sender = "[unlockaetheryte] " local usage = "\nThis command unlocks an aetheryte for the user.\nUsage: !unlockaetheryte " diff --git a/resources/scripts/events/common/GenericAetheryte.lua b/resources/scripts/events/common/GenericAetheryte.lua index 6c60479..69c362b 100644 --- a/resources/scripts/events/common/GenericAetheryte.lua +++ b/resources/scripts/events/common/GenericAetheryte.lua @@ -24,7 +24,7 @@ function onReturn(scene, results, player) -- local REGISTER_FAVORITE_DSTN = ??? -- Unable to obtain right now, seems to return 0 regardless -- local REGISTER_SECURITY_TOKEN_DSTN = ??? -- Unable to obtain right now, seems to return 0 regardless - local resultc = table.getn(results) -- TODO: Do we need to check this still? Can the favorite/security menus return more than 2, once they work? + local resultc = #results -- TODO: Do we need to check this still? Can the favorite/security menus return more than 2, once they work? local menu_option = results[1] local decision = results[2]