Skip to content

Commit ea65827

Browse files
authored
spectate.lua: make config public
Also improve error messages when missing command arguments
1 parent d40dbba commit ea65827

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

plugins/lua/spectate.lua

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,8 @@ local function load_state()
8484
function() config_file:write() end
8585
end
8686

87-
local config, save_state = load_state()
87+
-- global variables to make the UI script simpler
88+
_ENV.config, _ENV.save_state = load_state()
8889

8990
function refresh_cpp_config()
9091
for name,value in pairs(config) do
@@ -158,11 +159,15 @@ local function do_toggle()
158159
end
159160

160161
local function set_setting(args)
162+
local n = #args
163+
if n == 0 then
164+
qerror('missing key')
165+
end
161166
local key = table.remove(args, 1)
162167
if config[key] == nil then
163168
qerror('unknown setting: ' .. key)
164169
end
165-
local n = #args
170+
n = #args
166171
if n == 0 then
167172
qerror('missing value')
168173
end
@@ -221,6 +226,7 @@ function parse_commandline(args)
221226
elseif command == 'set' then
222227
set_setting(args)
223228
elseif command == 'overlay' then
229+
if #args == 0 then qerror('missing option') end
224230
set_overlay(args[1])
225231
else
226232
return false

0 commit comments

Comments
 (0)