mirror of
https://git.do.srb2.org/STJr/SRB2.git
synced 2025-03-22 10:52:23 +00:00
Merge branch 'titlemaplua' into 'master'
Titlemap Lua See merge request STJr/SRB2Internal!270
This commit is contained in:
commit
c82c2ee815
9 changed files with 27 additions and 50 deletions
|
@ -82,7 +82,6 @@ typedef enum
|
|||
|
||||
// Current menu parameters
|
||||
|
||||
extern UINT8 titlemapinaction;
|
||||
extern mobj_t *titlemapcameraref;
|
||||
extern char curbgname[8];
|
||||
extern SINT8 curfadevalue;
|
||||
|
|
|
@ -50,6 +50,7 @@ typedef enum
|
|||
} gameaction_t;
|
||||
|
||||
extern gamestate_t gamestate;
|
||||
extern UINT8 titlemapinaction;
|
||||
extern UINT8 ultimatemode; // was sk_insane
|
||||
extern gameaction_t gameaction;
|
||||
|
||||
|
|
|
@ -33,8 +33,6 @@
|
|||
|
||||
#define NOHUD if (hud_running)\
|
||||
return luaL_error(L, "HUD rendering code should not call this function!");
|
||||
#define INLEVEL if (gamestate != GS_LEVEL)\
|
||||
return luaL_error(L, "This function can only be used in a level!");
|
||||
|
||||
boolean luaL_checkboolean(lua_State *L, int narg) {
|
||||
luaL_checktype(L, narg, LUA_TBOOLEAN);
|
||||
|
|
|
@ -28,9 +28,6 @@ return luaL_error(L, "HUD rendering code should not call this function!");
|
|||
// for functions not allowed in hooks or coroutines (supercedes above)
|
||||
#define NOHOOK if (!lua_lumploading)\
|
||||
return luaL_error(L, "This function cannot be called from within a hook or coroutine!");
|
||||
// for functions only allowed within a level
|
||||
#define INLEVEL if (gamestate != GS_LEVEL)\
|
||||
return luaL_error(L, "This function can only be used in a level!");
|
||||
|
||||
static const char *cvname = NULL;
|
||||
|
||||
|
|
|
@ -333,8 +333,7 @@ static int lib_iterateSectorThinglist(lua_State *L)
|
|||
mobj_t *state = NULL;
|
||||
mobj_t *thing = NULL;
|
||||
|
||||
if (gamestate != GS_LEVEL)
|
||||
return luaL_error(L, "This function can only be used in a level!");
|
||||
INLEVEL
|
||||
|
||||
if (lua_gettop(L) < 2)
|
||||
return luaL_error(L, "Don't call sector.thinglist() directly, use it as 'for rover in sector.thinglist do <block> end'.");
|
||||
|
@ -369,8 +368,7 @@ static int lib_iterateSectorFFloors(lua_State *L)
|
|||
ffloor_t *state = NULL;
|
||||
ffloor_t *ffloor = NULL;
|
||||
|
||||
if (gamestate != GS_LEVEL)
|
||||
return luaL_error(L, "This function can only be used in a level!");
|
||||
INLEVEL
|
||||
|
||||
if (lua_gettop(L) < 2)
|
||||
return luaL_error(L, "Don't call sector.ffloors() directly, use it as 'for rover in sector.ffloors do <block> end'.");
|
||||
|
@ -1251,8 +1249,7 @@ static int bbox_get(lua_State *L)
|
|||
static int lib_iterateSectors(lua_State *L)
|
||||
{
|
||||
size_t i = 0;
|
||||
if (gamestate != GS_LEVEL)
|
||||
return luaL_error(L, "This function can only be used in a level!");
|
||||
INLEVEL
|
||||
if (lua_gettop(L) < 2)
|
||||
return luaL_error(L, "Don't call sectors.iterate() directly, use it as 'for sector in sectors.iterate do <block> end'.");
|
||||
lua_settop(L, 2);
|
||||
|
@ -1270,8 +1267,7 @@ static int lib_iterateSectors(lua_State *L)
|
|||
static int lib_getSector(lua_State *L)
|
||||
{
|
||||
int field;
|
||||
if (gamestate != GS_LEVEL)
|
||||
return luaL_error(L, "You cannot access this outside of a level!");
|
||||
INLEVEL
|
||||
lua_settop(L, 2);
|
||||
lua_remove(L, 1); // dummy userdata table is unused.
|
||||
if (lua_isnumber(L, 1))
|
||||
|
@ -1305,8 +1301,7 @@ static int lib_numsectors(lua_State *L)
|
|||
static int lib_iterateSubsectors(lua_State *L)
|
||||
{
|
||||
size_t i = 0;
|
||||
if (gamestate != GS_LEVEL)
|
||||
return luaL_error(L, "This function can only be used in a level!");
|
||||
INLEVEL
|
||||
if (lua_gettop(L) < 2)
|
||||
return luaL_error(L, "Don't call subsectors.iterate() directly, use it as 'for subsector in subsectors.iterate do <block> end'.");
|
||||
lua_settop(L, 2);
|
||||
|
@ -1324,8 +1319,7 @@ static int lib_iterateSubsectors(lua_State *L)
|
|||
static int lib_getSubsector(lua_State *L)
|
||||
{
|
||||
int field;
|
||||
if (gamestate != GS_LEVEL)
|
||||
return luaL_error(L, "You cannot access this outside of a level!");
|
||||
INLEVEL
|
||||
lua_settop(L, 2);
|
||||
lua_remove(L, 1); // dummy userdata table is unused.
|
||||
if (lua_isnumber(L, 1))
|
||||
|
@ -1359,8 +1353,7 @@ static int lib_numsubsectors(lua_State *L)
|
|||
static int lib_iterateLines(lua_State *L)
|
||||
{
|
||||
size_t i = 0;
|
||||
if (gamestate != GS_LEVEL)
|
||||
return luaL_error(L, "This function can only be used in a level!");
|
||||
INLEVEL
|
||||
if (lua_gettop(L) < 2)
|
||||
return luaL_error(L, "Don't call lines.iterate() directly, use it as 'for line in lines.iterate do <block> end'.");
|
||||
lua_settop(L, 2);
|
||||
|
@ -1378,8 +1371,7 @@ static int lib_iterateLines(lua_State *L)
|
|||
static int lib_getLine(lua_State *L)
|
||||
{
|
||||
int field;
|
||||
if (gamestate != GS_LEVEL)
|
||||
return luaL_error(L, "You cannot access this outside of a level!");
|
||||
INLEVEL
|
||||
lua_settop(L, 2);
|
||||
lua_remove(L, 1); // dummy userdata table is unused.
|
||||
if (lua_isnumber(L, 1))
|
||||
|
@ -1413,8 +1405,7 @@ static int lib_numlines(lua_State *L)
|
|||
static int lib_iterateSides(lua_State *L)
|
||||
{
|
||||
size_t i = 0;
|
||||
if (gamestate != GS_LEVEL)
|
||||
return luaL_error(L, "This function can only be used in a level!");
|
||||
INLEVEL
|
||||
if (lua_gettop(L) < 2)
|
||||
return luaL_error(L, "Don't call sides.iterate() directly, use it as 'for side in sides.iterate do <block> end'.");
|
||||
lua_settop(L, 2);
|
||||
|
@ -1432,8 +1423,7 @@ static int lib_iterateSides(lua_State *L)
|
|||
static int lib_getSide(lua_State *L)
|
||||
{
|
||||
int field;
|
||||
if (gamestate != GS_LEVEL)
|
||||
return luaL_error(L, "You cannot access this outside of a level!");
|
||||
INLEVEL
|
||||
lua_settop(L, 2);
|
||||
lua_remove(L, 1); // dummy userdata table is unused.
|
||||
if (lua_isnumber(L, 1))
|
||||
|
@ -1467,8 +1457,7 @@ static int lib_numsides(lua_State *L)
|
|||
static int lib_iterateVertexes(lua_State *L)
|
||||
{
|
||||
size_t i = 0;
|
||||
if (gamestate != GS_LEVEL)
|
||||
return luaL_error(L, "This function can only be used in a level!");
|
||||
INLEVEL
|
||||
if (lua_gettop(L) < 2)
|
||||
return luaL_error(L, "Don't call vertexes.iterate() directly, use it as 'for vertex in vertexes.iterate do <block> end'.");
|
||||
lua_settop(L, 2);
|
||||
|
@ -1486,8 +1475,7 @@ static int lib_iterateVertexes(lua_State *L)
|
|||
static int lib_getVertex(lua_State *L)
|
||||
{
|
||||
int field;
|
||||
if (gamestate != GS_LEVEL)
|
||||
return luaL_error(L, "You cannot access this outside of a level!");
|
||||
INLEVEL
|
||||
lua_settop(L, 2);
|
||||
lua_remove(L, 1); // dummy userdata table is unused.
|
||||
if (lua_isnumber(L, 1))
|
||||
|
@ -1523,8 +1511,7 @@ static int lib_numvertexes(lua_State *L)
|
|||
static int lib_iterateSegs(lua_State *L)
|
||||
{
|
||||
size_t i = 0;
|
||||
if (gamestate != GS_LEVEL)
|
||||
return luaL_error(L, "This function can only be used in a level!");
|
||||
INLEVEL
|
||||
if (lua_gettop(L) < 2)
|
||||
return luaL_error(L, "Don't call segs.iterate() directly, use it as 'for seg in segs.iterate do <block> end'.");
|
||||
lua_settop(L, 2);
|
||||
|
@ -1542,8 +1529,7 @@ static int lib_iterateSegs(lua_State *L)
|
|||
static int lib_getSeg(lua_State *L)
|
||||
{
|
||||
int field;
|
||||
if (gamestate != GS_LEVEL)
|
||||
return luaL_error(L, "You cannot access this outside of a level!");
|
||||
INLEVEL
|
||||
lua_settop(L, 2);
|
||||
lua_remove(L, 1); // dummy userdata table is unused.
|
||||
if (lua_isnumber(L, 1))
|
||||
|
@ -1577,8 +1563,7 @@ static int lib_numsegs(lua_State *L)
|
|||
static int lib_iterateNodes(lua_State *L)
|
||||
{
|
||||
size_t i = 0;
|
||||
if (gamestate != GS_LEVEL)
|
||||
return luaL_error(L, "This function can only be used in a level!");
|
||||
INLEVEL
|
||||
if (lua_gettop(L) < 2)
|
||||
return luaL_error(L, "Don't call nodes.iterate() directly, use it as 'for node in nodes.iterate do <block> end'.");
|
||||
lua_settop(L, 2);
|
||||
|
@ -1596,8 +1581,7 @@ static int lib_iterateNodes(lua_State *L)
|
|||
static int lib_getNode(lua_State *L)
|
||||
{
|
||||
int field;
|
||||
if (gamestate != GS_LEVEL)
|
||||
return luaL_error(L, "You cannot access this outside of a level!");
|
||||
INLEVEL
|
||||
lua_settop(L, 2);
|
||||
lua_remove(L, 1); // dummy userdata table is unused.
|
||||
if (lua_isnumber(L, 1))
|
||||
|
|
|
@ -816,8 +816,7 @@ static int mapthing_set(lua_State *L)
|
|||
static int lib_iterateMapthings(lua_State *L)
|
||||
{
|
||||
size_t i = 0;
|
||||
if (gamestate != GS_LEVEL)
|
||||
return luaL_error(L, "This function can only be used in a level!");
|
||||
INLEVEL
|
||||
if (lua_gettop(L) < 2)
|
||||
return luaL_error(L, "Don't call mapthings.iterate() directly, use it as 'for mapthing in mapthings.iterate do <block> end'.");
|
||||
lua_settop(L, 2);
|
||||
|
@ -835,8 +834,7 @@ static int lib_iterateMapthings(lua_State *L)
|
|||
static int lib_getMapthing(lua_State *L)
|
||||
{
|
||||
int field;
|
||||
if (gamestate != GS_LEVEL)
|
||||
return luaL_error(L, "You cannot access this outside of a level!");
|
||||
INLEVEL
|
||||
lua_settop(L, 2);
|
||||
lua_remove(L, 1); // dummy userdata table is unused.
|
||||
if (lua_isnumber(L, 1))
|
||||
|
|
|
@ -25,8 +25,7 @@
|
|||
static int lib_iteratePlayers(lua_State *L)
|
||||
{
|
||||
INT32 i = -1;
|
||||
if (gamestate != GS_LEVEL)
|
||||
return luaL_error(L, "This function can only be used in a level!");
|
||||
INLEVEL
|
||||
if (lua_gettop(L) < 2)
|
||||
{
|
||||
//return luaL_error(L, "Don't call players.iterate() directly, use it as 'for player in players.iterate do <block> end'.");
|
||||
|
@ -53,8 +52,7 @@ static int lib_getPlayer(lua_State *L)
|
|||
{
|
||||
const char *field;
|
||||
// i -> players[i]
|
||||
if (gamestate != GS_LEVEL)
|
||||
return luaL_error(L, "You cannot access this outside of a level!");
|
||||
INLEVEL
|
||||
if (lua_type(L, 2) == LUA_TNUMBER)
|
||||
{
|
||||
lua_Integer i = luaL_checkinteger(L, 2);
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
#include "m_fixed.h"
|
||||
#include "doomtype.h"
|
||||
#include "d_player.h"
|
||||
#include "g_state.h"
|
||||
|
||||
#include "blua/lua.h"
|
||||
#include "blua/lualib.h"
|
||||
|
@ -97,4 +98,7 @@ void COM_Lua_f(void);
|
|||
// uncomment if you want seg_t/node_t in Lua
|
||||
// #define HAVE_LUA_SEGS
|
||||
|
||||
#define INLEVEL if (gamestate != GS_LEVEL && !titlemapinaction)\
|
||||
return luaL_error(L, "This can only be used in a level!");
|
||||
|
||||
#endif
|
||||
|
|
|
@ -56,8 +56,7 @@ static int lib_iterateThinkers(lua_State *L)
|
|||
thinker_t *th = NULL, *next = NULL;
|
||||
struct iterationState *it;
|
||||
|
||||
if (gamestate != GS_LEVEL)
|
||||
return luaL_error(L, "This function can only be used in a level!");
|
||||
INLEVEL
|
||||
|
||||
it = luaL_checkudata(L, 1, META_ITERATIONSTATE);
|
||||
|
||||
|
@ -112,8 +111,7 @@ static int lib_startIterate(lua_State *L)
|
|||
{
|
||||
struct iterationState *it;
|
||||
|
||||
if (gamestate != GS_LEVEL)
|
||||
return luaL_error(L, "This function can only be used in a level!");
|
||||
INLEVEL
|
||||
|
||||
lua_pushvalue(L, lua_upvalueindex(1));
|
||||
it = lua_newuserdata(L, sizeof(struct iterationState));
|
||||
|
|
Loading…
Reference in a new issue