Terrain library for Lua (`terrain_t`, `t_splash_t`, `t_footstep_t`, `t_overlay_t`)
Summary
This branch exposes terrain_t
, t_splash_t
, t_footstep_t
, t_overlay_t
, their respective global iteratable tables, and terrain-related functions, as well as exposing terrain
from mobj_t
, and stairjank
and outrun
from player_t
to Lua.
The game comes with no default overlays, so that aspect is largely untested - I have no reason to think it would not work, though.
It changes the following:
- Exposes the following variables:
-
terrain_t
object:- get:
valid
,name
,hash
,splashid
,footstepid
,overlayid
,friction
,offroad
,damagetype
,trickpanel
,speedpad
,speedpadangle
,springstrength
,springstarcolor
,outrun
,floorclip
,flags
- get:
-
t_splash_t
object:- get:
valid
,name
,hash
,mobjtype
,sfx
,scale
,color
,pushh
,pushv
,spread
,cone
,numparticles
- get:
-
t_footstep_t
object:- get:
valid
,name
,hash
,mobjtype
,sfx
,scale
,color
,pushh
,pushv
,spread
,cone
,sfxfreq
,frequency
,requiredspeed
- get:
-
t_overlay_t
object:- get:
valid
,name
,hash
,states
,scale
,color
,speed
- get:
-
mobj_t
object:- get and set:
terrain
- get and set:
-
player_t
object:- get and set:
stairjank
,outrun
- get and set:
-
- Exposes the following globals:
-
terrains
(table with all available terrains, can be accessed through index or name such asterrains[0]
orterrains["Default"]
),#terrains
(counts how many terrains there are),terrains.iterate
(iteratable for all terrains). -
footsteps
,#footsteps
,terrains.iterate
(likewise, but with footsteps). -
splashes
,#splashes
,splashes.iterate
(likewise, but with splashes). -
overlays
,#overlays
,overlays.iterate
(likewise, but with overlays).
-
- Exposes the following constants:
-
t_overlay_action_t
:TOV_UNDEFINED
,TOV_STILL
,TOV_MOVING
,TOV__MAX
-
terrain_flags_t
:TRF_LIQUID
,TRF_SNEAKERPANEL
,TRF_STAIRJANK
,TRF_TRIPWIRE
,TRF_REMAP
-
- Exposes the following functions:
terrain_t K_GetDefaultTerrain()
terrain_t K_GetTerrainForTextureName(string name)
terrain_t K_GetTerrainForTextureNum(integer id)
void K_ProcessTerrainEffect(mobj_t mo)
void K_SetDefaultFriction(mobj_t mo)
void K_SpawnSplashForMobj(mobj_t mo, [fixed_t impact])
void K_HandleFootstepParticles(mobj_t mo)
void K_UpdateTerrainOverlay(mobj_t mo)
-
boolean K_TerrainHasAffect(terrain_t terrain, [boolean badonly])
(Note: this will report every terrain as having an affect except for NoRemap, likely because of the friction condition being> 0
rather than!= ORIG_FRICTION
. I didn't fix this, but let me know if this warrants a commit to do so.)
Testing
Testing environment: ringracers_terrainLib.exe -console -skipintro -warp RR_TESTRUN +addfile terraintest.lua
I used a script, terraintest.lua, to test the following additions:
- It will print all exposed constants in the console.
- Has a HUD hook that will display all of the terrain values that the player is standing on. Can be disabled using
terrainhuddebug 0
. -
testiterateterrain
/testforloopterrain
,testiteratefootstep
/testforloopfootstep
,testiteratesplash
/testforloopsplash
andtestiterateoverlay
/testforloopoverlay
tests for..do loops and the iterate functions directed at theterrains
,footsteps
,splashes
andoverlays
globals respectively, by printing all of their values, as well as their affectness. Note that there are no overlays by default in the base game, so it will print nothing for those cases. -
testterrain
allows the player to set any given terrain to their mobj, runningK_ProcessTerrainEffect
,K_SetDefaultFriction
,K_HandleFootstepParticles
in the process. -
findterrain
,findsplash
,findfootstep
andfindoverlay
take a number or string, and it will print the values of the object that corresponds with that ID or string. -
defaultterrain
prints the info of the default terrain, runningK_GetDefaultTerrain
in the process. -
splashme
runsK_SpawnSplashForMobj
on the player mobj, with an optional parameter that allows to set the strength of the splash. -
findterrainonfloor
runsK_GetTerrainForTextureName
to get the terrain of the floor and ceiling, printing their values. -
findterrainonwalls
runsK_GetTerrainForTextureNum
to get the terrain of all walls inside the sector, printing their values.
Changelog
- Adding the following global tables to Lua:
terrains
,splashes
,footsteps
,overlays
- Exposed
terrain_t
,t_splash_t
,t_footstep_t
,t_overlay_t
types to Lua (get only). - Exposed
player_t
membersstairjank
andoutrun
to Lua (get and set). - Exposed
mobj_t
memberterrain
to Lua (get and set). - Exposed
t_overlay_action_t
constants:TOV_UNDEFINED
,TOV_STILL
,TOV_MOVING
,TOV__MAX
- Exposed
terrain_flags_t
constants:TRF_LIQUID
,TRF_SNEAKERPANEL
,TRF_STAIRJANK
,TRF_TRIPWIRE
,TRF_REMAP
- Exposed the following terrain-related functions to Lua:
K_GetDefaultTerrain
,K_GetTerrainForTextureName
,K_GetTerrainForTextureNum
,K_ProcessTerrainEffect
,K_SetDefaultFriction
,K_SpawnSplashForMobj
,K_HandleFootstepParticles
,K_UpdateTerrainOverlay
,K_TerrainHasAffect
.