Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
SRB2
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Package registry
Model registry
Operate
Terraform modules
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
SSNTails
SRB2
Commits
2eaf02d2
Commit
2eaf02d2
authored
Feb 3, 2020
by
LJ Sonic
Browse files
Options
Downloads
Patches
Plain Diff
Let Lua access spectators mobjs
parent
5a524f21
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/lua_playerlib.c
+5
-1
5 additions, 1 deletion
src/lua_playerlib.c
with
5 additions
and
1 deletion
src/lua_playerlib.c
+
5
−
1
View file @
2eaf02d2
...
@@ -97,6 +97,10 @@ static int player_get(lua_State *L)
...
@@ -97,6 +97,10 @@ static int player_get(lua_State *L)
lua_pushboolean
(
L
,
true
);
lua_pushboolean
(
L
,
true
);
else
if
(
fastcmp
(
field
,
"name"
))
else
if
(
fastcmp
(
field
,
"name"
))
lua_pushstring
(
L
,
player_names
[
plr
-
players
]);
lua_pushstring
(
L
,
player_names
[
plr
-
players
]);
else
if
(
fastcmp
(
field
,
"realmo"
))
LUA_PushUserdata
(
L
,
plr
->
mo
,
META_MOBJ
);
// Kept for backward-compatibility
// Should be fixed to work like "realmo" later
else
if
(
fastcmp
(
field
,
"mo"
))
else
if
(
fastcmp
(
field
,
"mo"
))
{
{
if
(
plr
->
spectator
)
if
(
plr
->
spectator
)
...
@@ -396,7 +400,7 @@ static int player_set(lua_State *L)
...
@@ -396,7 +400,7 @@ static int player_set(lua_State *L)
if
(
hud_running
)
if
(
hud_running
)
return
luaL_error
(
L
,
"Do not alter player_t in HUD rendering code!"
);
return
luaL_error
(
L
,
"Do not alter player_t in HUD rendering code!"
);
if
(
fastcmp
(
field
,
"mo"
))
{
if
(
fastcmp
(
field
,
"mo"
)
||
fastcmp
(
field
,
"realmo"
)
)
{
mobj_t
*
newmo
=
*
((
mobj_t
**
)
luaL_checkudata
(
L
,
3
,
META_MOBJ
));
mobj_t
*
newmo
=
*
((
mobj_t
**
)
luaL_checkudata
(
L
,
3
,
META_MOBJ
));
plr
->
mo
->
player
=
NULL
;
// remove player pointer from old mobj
plr
->
mo
->
player
=
NULL
;
// remove player pointer from old mobj
(
newmo
->
player
=
plr
)
->
mo
=
newmo
;
// set player pointer for new mobj, and set new mobj as the player's mobj
(
newmo
->
player
=
plr
)
->
mo
=
newmo
;
// set player pointer for new mobj, and set new mobj as the player's mobj
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment