Add mobj.localskin and player.localskin fields
This commit is contained in:
1 parent
859c0181a1
commit
939aedd384
2 files changed
+57
-3
No files matched your search
+31
-3
@@ -50,6 +50,8 @@ int mobj_state_setter(lua_State *L);
|
||||
int mobj_flags_setter(lua_State *L);
|
||||
int mobj_skin_getter(lua_State *L);
|
||||
int mobj_skin_setter(lua_State *L);
|
||||
int mobj_localskin_getter(lua_State *L);
|
||||
int mobj_localskin_setter(lua_State *L);
|
||||
int mobj_color_setter(lua_State *L);
|
||||
int mobj_bnext_noset(lua_State *L);
|
||||
int mobj_bprev_unimplemented(lua_State *L);
|
||||
@@ -108,6 +110,7 @@ static const udata_field_t mobj_fields[] = {
|
||||
FIELD(mobj_t, flags2, udatalib_getter_uint32, udatalib_setter_uint32),
|
||||
FIELD(mobj_t, eflags, udatalib_getter_uint32, udatalib_setter_uint32),
|
||||
FIELD(mobj_t, skin, mobj_skin_getter, mobj_skin_setter),
|
||||
FIELD(mobj_t, localskin, mobj_localskin_getter, mobj_localskin_setter),
|
||||
FIELD(mobj_t, color, udatalib_getter_uint8, mobj_color_setter),
|
||||
FIELD(mobj_t, bnext, udatalib_getter_mobj, mobj_bnext_noset),
|
||||
FIELD(mobj_t, bprev, mobj_bprev_unimplemented, mobj_bprev_unimplemented),
|
||||
@@ -384,7 +387,7 @@ int mobj_skin_setter(lua_State *L)
|
||||
char skin[SKINNAMESIZE+1]; // all skin names are limited to this length
|
||||
strlcpy(skin, luaL_checkstring(L, 2), sizeof skin);
|
||||
strlwr(skin); // all skin names are lowercase
|
||||
for (i = 0; i < numskins; i++) {
|
||||
for (i = 0; i < numskins; i++)
|
||||
{
|
||||
if (fastcmp(skins[i].name, skin))
|
||||
{
|
||||
@@ -393,11 +396,36 @@ int mobj_skin_setter(lua_State *L)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return luaL_error(L, "mobj.skin '%s' not found!", skin);
|
||||
}
|
||||
|
||||
int mobj_localskin_getter(lua_State *L)
|
||||
{
|
||||
mobj_t *mo = GETMO();
|
||||
|
||||
if (mo->localskin)
|
||||
lua_pushstring(L, ((skin_t *)mo->localskin)->name);
|
||||
else
|
||||
lua_pushnil(L);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int mobj_localskin_setter(lua_State *L)
|
||||
{
|
||||
mobj_t *mo = GETMO();
|
||||
|
||||
// TODO - add ability to set localskin to non-player mobjs
|
||||
// Will probably just need to reimplement SetLocalPlayerSkin as something
|
||||
// like SetLocalObjectSkin
|
||||
if (!mo->player)
|
||||
return luaL_error(L, "mobj.localskin can't be set for non-player mobjs!");
|
||||
|
||||
SetLocalPlayerSkin(mo->player - players, luaL_checkstring(L, 2), NULL);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int mobj_color_setter(lua_State *L)
|
||||
{
|
||||
mobj_t *mo = GETMO();
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
#ifdef HAVE_BLUA
|
||||
#include "fastcmp.h"
|
||||
#include "r_main.h"
|
||||
#include "r_things.h"
|
||||
#include "p_mobj.h"
|
||||
#include "d_player.h"
|
||||
#include "g_game.h"
|
||||
@@ -44,6 +45,8 @@ int player_bot_noset(lua_State *L);
|
||||
int player_splitscreenindex_noset(lua_State *L);
|
||||
int player_ping_getter(lua_State *L);
|
||||
int player_ping_noset(lua_State *L);
|
||||
int player_localskin_getter(lua_State *L);
|
||||
int player_localskin_setter(lua_State *L);
|
||||
|
||||
// Non synch safe!
|
||||
int player_sliproll_getter(lua_State *L);
|
||||
@@ -71,6 +74,7 @@ static const udata_field_t player_fields[] = {
|
||||
FIELD(player_t, flashcount, udatalib_getter_uint16, udatalib_setter_uint16),
|
||||
FIELD(player_t, flashpal, udatalib_getter_uint16, udatalib_setter_uint16),
|
||||
FIELD(player_t, skincolor, udatalib_getter_uint8, player_skincolor_setter),
|
||||
FIELD(player_t, localskin, player_localskin_getter, player_localskin_setter),
|
||||
FIELD(player_t, score, udatalib_getter_uint32, udatalib_setter_uint32),
|
||||
FIELD(player_t, dashspeed, udatalib_getter_fixed, udatalib_setter_fixed),
|
||||
FIELD(player_t, dashtime, udatalib_getter_int32, udatalib_setter_int32),
|
||||
@@ -282,6 +286,28 @@ int player_skincolor_setter(lua_State *L)
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int player_localskin_getter(lua_State *L)
|
||||
{
|
||||
player_t *plr = GETPLAYER();
|
||||
|
||||
if (plr->localskin)
|
||||
lua_pushstring(L, (plr->skinlocal ? localskins : skins)[plr->localskin - 1].name);
|
||||
else
|
||||
lua_pushnil(L);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int player_localskin_setter(lua_State *L)
|
||||
{
|
||||
player_t *plr = GETPLAYER();
|
||||
|
||||
SetLocalPlayerSkin(plr - players, luaL_checkstring(L, 2), NULL);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int player_axis_setter(lua_State *L)
|
||||
{
|
||||
mobj_t **axis;
|
||||
|
||||
Reference in new issue
Block a user