Garry's Mod

Garry's Mod

Not enough ratings
BlockStep Lua API Documentation
By mrbooboostank
How to configure BlockStep to support your maps and custom gamemodes
   
Award
Favorite
Favorited
Unfavorite
Quickstart
The easiest way to configure a map to use BlockStep is to install the BlockStep addon and follow the interactive setup provided by the BlockStep tool in the Tool Gun. If you're a regular player, this process will create console variables with the format blockstep_map_name_etc, and you may ignore the rest of this guide. A set of blockstep_override console variables are also available for you to use, which will affect the entire BlockStep addon instead of only the current map.
https://steamhost.cn/steamcommunity_com/sharedfiles/filedetails/?id=3408399013
If you're a modder and you know the map's name and its block size (in Hammer Units), then a map can be supported by filling in this template without the use of the BlockStep tool:

Create a file called gm_example_map.lua, and fill it with these lines:
blockstep.SetDefaultBlockSize( insert_block_size_here )
blockstep.SetDefaultStepHeight( 1 )
blockstep.SetDefaultJumpHeight( 1.25 )
blockstep.SetDefaultShouldAccountForGravity( true )

If you're the map's creator, place gm_example_map.lua in:
[your_addons_name]/lua/blockstep_maps/

Otherwise, place the lua file in:
[your_addons_name]/lua/blockstep_thirdparty/
API Load Order
To provide the best experience for players, BlockStep loads its default values in a specific order

(Top overrides bottom):
  • blockstep_override convars (Allows customization by players for all maps)
  • blockstep_map convars (Allows customization by players for specific maps)
  • blockstep_thirdparty folder (Allows support for all maps from workshoppers)
  • blockstep_maps folder (Allows direct support from mapmakers)
  • blockstep_defaults folder (Allows support for maps I like)
  • autorun/blockstep.lua (Ensures console variables are always created)
Documentation
BlockStep is a serverside library first and foremost. This means that, for server owners, clients need not install the addon. Clients will only need to install the addon if they intend to use the BlockStep tool, as it requires a language file to be downloaded for text to be legible.

command blockstep_debug
  • Prints debug info about the BlockStep library.

function blockstep.SetDefaultBlockSize( number desiredDefault = -1 ) saves console variable to blockstep.BlockSizeConVar
  • Size of this map's blocks in Hammer units. Set to a negative value to effectively disable the addon.

function blockstep.SetDefaultStepHeight( number desiredDefault = -1 ) saves console variable to blockstep.StepHeightConVar
  • Maximum block height players can step up onto. Set to a negative value to disable this aspect of the addon.

function blockstep.SetDefaultJumpHeight( number desiredDefault = -1 ) saves console variable to blockstep.JumpHeightConVar
  • How high players can jump in blocks. Set to a negative value to disable this aspect of the addon.

function blockstep.SetDefaultShouldAccountForGravity( boolean desiredDefault = false ) saves console variable to blockstep.ShouldAccountForGravityConVar
  • When enabled, jump height will recalculate if sv_gravity is changed during play. If players could jump 1 block on Earth, they'll continue jumping 1 block on the Moon.





function blockstep.GetBlockSizeUserValue()
  • Returns the size of this map's blocks in Hammer units while respecting if the user is overriding this value. Use this getter when able.

function blockstep.GetStepHeightUserValue()
  • Returns the maximum block height players can step up onto, while respecting if the user is overriding this value. Use this getter when able.

function blockstep.GetJumpHeightUserValue()
  • Returns how high players can jump in blocks, while respecting if the user is overriding this value. Use this getter when able.

function blockstep.GetShouldAccountForGravityUserValue()
  • Returns if jump height will recalculate if sv_gravity is changed during play, while respecting if the user is overriding this value. Use this getter when able.





hook SetPlayerStepHeight( Player player, number providedStepHeight )
  • BlockStep uses this hook under the identifier "blockstep_setplayerstepheight". You may remove BlockStep's implementation of this hook for the purposes of your gamemode or server.

hook SetPlayerJumpPower( Player player, number providedJumpPower )
  • BlockStep uses this hook under the identifier "blockstep_setplayerjumppower". You may remove BlockStep's implementation of this hook for the purposes of your gamemode or server.

function blockstep.UpdatePlayerAttributes( Player player )
  • Calls the SetPlayerStepHeight and SetPlayerJumpPower hooks on the specified player. If no player is specified, this function calls the hooks for every player in the server. BlockStep by default calls this from the hook identifier "blockstep_playersetmodel".





field number blockstep.JumpPower
  • BlockStep's stored jump power for the current session. Good for reading, don't write to.

field number blockstep.StepHeight
  • BlockStep's stored step height for the current session. Good for reading, don't write to.

field number blockstep.DefaultJumpPower = 200
  • BlockStep's default jump power. Feel free to overwrite for the purposes of your gamemode or server.

field number blockstep.DefaultStepHeight = 18
  • BlockStep's default step height. Freel free to overwrite for the purposes of your gamemode or server.
Thanks for reading
If you try BlockStep, let me know what you think
Buymeacoffee[buymeacoffee.com]
Steam trade
YouTube channel
BlockStep on GitHub[github.com]
1 Comments
kittenwitdamitten 26 Jan @ 6:14pm 
tyt