The source project of this merge request has been removed.
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_tobject:- get:
valid,name,hash,splashid,footstepid,overlayid,friction,offroad,damagetype,trickpanel,speedpad,speedpadangle,springstrength,springstarcolor,outrun,floorclip,flags
- get:
-
t_splash_tobject:- get:
valid,name,hash,mobjtype,sfx,scale,color,pushh,pushv,spread,cone,numparticles
- get:
-
t_footstep_tobject:- get:
valid,name,hash,mobjtype,sfx,scale,color,pushh,pushv,spread,cone,sfxfreq,frequency,requiredspeed
- get:
-
t_overlay_tobject:- get:
valid,name,hash,states,scale,color,speed
- get:
-
mobj_tobject:- get and set:
terrain
- get and set:
-
player_tobject:- 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> 0rather 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/testforloopsplashandtestiterateoverlay/testforloopoverlaytests for..do loops and the iterate functions directed at theterrains,footsteps,splashesandoverlaysglobals 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. -
testterrainallows the player to set any given terrain to their mobj, runningK_ProcessTerrainEffect,K_SetDefaultFriction,K_HandleFootstepParticlesin the process. -
findterrain,findsplash,findfootstepandfindoverlaytake a number or string, and it will print the values of the object that corresponds with that ID or string. -
defaultterrainprints the info of the default terrain, runningK_GetDefaultTerrainin the process. -
splashmerunsK_SpawnSplashForMobjon the player mobj, with an optional parameter that allows to set the strength of the splash. -
findterrainonfloorrunsK_GetTerrainForTextureNameto get the terrain of the floor and ceiling, printing their values. -
findterrainonwallsrunsK_GetTerrainForTextureNumto 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_ttypes to Lua (get only). - Exposed
player_tmembersstairjankandoutrunto Lua (get and set). - Exposed
mobj_tmemberterrainto Lua (get and set). - Exposed
t_overlay_action_tconstants:TOV_UNDEFINED,TOV_STILL,TOV_MOVING,TOV__MAX - Exposed
terrain_flags_tconstants: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.