UFO: Alien Invasion
Toggle main menu visibility
Loading...
Searching...
No Matches
scripts_lua.cpp
Go to the documentation of this file.
1
5
6
/*
7
Copyright (C) 2002-2025 UFO: Alien Invasion.
8
9
This program is free software; you can redistribute it and/or
10
modify it under the terms of the GNU General Public License
11
as published by the Free Software Foundation; either version 2
12
of the License, or (at your option) any later version.
13
14
This program is distributed in the hope that it will be useful,
15
but WITHOUT ANY WARRANTY; without even the implied warranty of
16
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
17
18
See the GNU General Public License for more details.
19
20
You should have received a copy of the GNU General Public License
21
along with this program; if not, write to the Free Software
22
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23
24
*/
25
26
#include "
scripts_lua.h
"
27
#include "
../shared/cxx.h
"
28
29
int
Com_LuaIsNilOrTable
(lua_State* L,
int
index
) {
30
return
(lua_isnil(L,
index
) || lua_istable(L,
index
));
31
}
32
36
linkedList_t
*
Com_LuaTableToStringList
(lua_State* L,
int
index
) {
37
if
(lua_isnil(L,
index
))
38
return
nullptr
;
39
40
linkedList_t
* result =
nullptr
;
41
/* table is in the stack at 'index' */
42
lua_pushnil(L);
/* first key */
43
while
(lua_next(L,
index
) != 0) {
44
/* 'key' at index -2 and 'value' at index -1 */
45
const
char
*
v
= lua_tostring(L, -1);
46
if
(
v
)
47
LIST_AddString
(&result,
v
);
48
/* removes 'value', keeps 'key' for next iteration */
49
lua_pop(L, 1);
50
}
51
return
result;
52
}
cxx.h
LIST_AddString
void LIST_AddString(linkedList_t **listDest, const char *data)
Adds an string to a new or to an already existing linked list. The string is copied here.
Definition
list.cpp:139
v
QGL_EXTERN int GLboolean GLfloat * v
Definition
r_gl.h:120
index
QGL_EXTERN GLuint index
Definition
r_gl.h:110
Com_LuaTableToStringList
linkedList_t * Com_LuaTableToStringList(lua_State *L, int index)
Convert a lua table to a linkedList of character strings.
Definition
scripts_lua.cpp:36
Com_LuaIsNilOrTable
int Com_LuaIsNilOrTable(lua_State *L, int index)
Definition
scripts_lua.cpp:29
scripts_lua.h
Header for lua script functions.
linkedList_t
Definition
list.h:30
src
common
scripts_lua.cpp
Generated on __DATE__ __TIME__ for UFO: Alien Invasion by
1.17.0