Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
SRB2
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
STJr
SRB2
Merge requests
!1205
Set cvars directly from Lua
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
Set cvars directly from Lua
set-cvars
into
next
Overview
4
Commits
1
Pipelines
0
Changes
1
Merged
James R.
requested to merge
set-cvars
into
next
4 years ago
Overview
4
Commits
1
Pipelines
0
Changes
1
Expand
Silly
COM_BufInsertText
.
5
0
Merge request reports
Compare
next
next (base)
and
latest version
latest version
39ccd12f
1 commit,
4 years ago
1 file
+
43
−
0
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
src/lua_consolelib.c
+
43
−
0
Options
@@ -432,6 +432,46 @@ static int lib_cvFindVar(lua_State *L)
return
1
;
}
static
int
CVarSetFunction
(
lua_State
*
L
,
void
(
*
Set
)(
consvar_t
*
,
const
char
*
),
void
(
*
SetValue
)(
consvar_t
*
,
INT32
)
){
consvar_t
*
cvar
=
(
consvar_t
*
)
luaL_checkudata
(
L
,
1
,
META_CVAR
);
switch
(
lua_type
(
L
,
2
))
{
case
LUA_TSTRING
:
(
*
Set
)(
cvar
,
lua_tostring
(
L
,
2
));
break
;
case
LUA_TNUMBER
:
(
*
SetValue
)(
cvar
,
(
INT32
)
lua_tonumber
(
L
,
2
));
break
;
default:
return
luaL_typerror
(
L
,
1
,
"string or number"
);
}
return
0
;
}
static
int
lib_cvSet
(
lua_State
*
L
)
{
return
CVarSetFunction
(
L
,
CV_Set
,
CV_SetValue
);
}
static
int
lib_cvStealthSet
(
lua_State
*
L
)
{
return
CVarSetFunction
(
L
,
CV_StealthSet
,
CV_StealthSetValue
);
}
static
int
lib_cvAddValue
(
lua_State
*
L
)
{
consvar_t
*
cvar
=
(
consvar_t
*
)
luaL_checkudata
(
L
,
1
,
META_CVAR
);
CV_AddValue
(
cvar
,
(
INT32
)
luaL_checknumber
(
L
,
2
));
return
0
;
}
// CONS_Printf for a single player
// Use 'print' in baselib for a global message.
static
int
lib_consPrintf
(
lua_State
*
L
)
@@ -472,6 +512,9 @@ static luaL_Reg lib[] = {
{
"COM_BufInsertText"
,
lib_comBufInsertText
},
{
"CV_RegisterVar"
,
lib_cvRegisterVar
},
{
"CV_FindVar"
,
lib_cvFindVar
},
{
"CV_Set"
,
lib_cvSet
},
{
"CV_StealthSet"
,
lib_cvStealthSet
},
{
"CV_AddValue"
,
lib_cvAddValue
},
{
"CONS_Printf"
,
lib_consPrintf
},
{
NULL
,
NULL
}
};
Loading