Reg-ex problem
Posted: Thu Oct 06, 2022 12:28 pm
I've run this in a local Lua session:
I use the same reg-ex to parse the arguments to a command:
Calling that function in the game as
will get the correct id, but "owner" will always be nil:
Any idea why this works in a regular Lua session but not in the game?
Code: Select all
Lua 5.2.4 Copyright (C) 1994-2015 Lua.org, PUC-Rio
> x = " 72 asdf"
> id, name = x:match("^%s*(%d+)%s*(.-)%s*$")
> print(id, "|"..tostring(name).."|")
72 |asdf|
Code: Select all
debugging_commands["set-GCKI-owner"] = function(command)
debugging.entered_command(command)
local id, owner = command.parameter and
command.parameter:match("^%s*(%d+)%s*(.-)%s*$")
AD.show("id", id)
AD.show("owner", owner)
end
Code: Select all
/set-GCKI-owner 72, asdf
Code: Select all
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
Entered function for command AD-set-GCKI-owner(tick = 65147, player_index = 1, parameter = " 72, asdf")
(@__autodrive__/libs/debugging.lua: 754)
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
10289.915 Script @__autodrive__/libs/debugging.lua:173: id: 72
10289.915 Script @__autodrive__/libs/debugging.lua:173: owner: nil