How do I use stuff like mo AND player in one thing?

While tryna learn srb2 modding stuff, I've seen in the code of mods stuff like player.mo for example, and I was wondering how people are able to use both of those things without the game saying something like 'attempt to index global 'player' (a nil value)', since I can't seem to wrap my head around it.
 
While tryna learn srb2 modding stuff, I've seen in the code of mods stuff like player.mo for example, and I was wondering how people are able to use both of those things without the game saying something like 'attempt to index global 'player' (a nil value)', since I can't seem to wrap my head around it.
player and mo represent player_t and mobj_t userdata.
They hold preexisting values by the time you read them so there’s no need to index a global called player because player already means something.

Check out this page for more information.
 
To be more specific, there is a variable in player_t userdata called "mo" which points to the mobj_t userdata of that player's object in the level.
Typically you'll encounter player_t userdata in hooks like PlayerThink, where it exists as a given variable to start with. (Most people tend to name it player, which is where that comes from).
 

Who is viewing this thread (Total: 0, Members: 0, Guests: 0)

Back
Top