Skip to content

Go: Server, ticks and system information

Functions

CurrentTick

Go
func CurrentTick() (uint64, error)

CurrentTick is the server's tick counter.

TickDeltaTime

Go
func TickDeltaTime() (float64, error)

TickDeltaTime is the length of the last tick, in seconds.

PlayerCount

Go
func PlayerCount() (int32, error)

PlayerCount is how many players are online.

SimPaused

Go
func SimPaused() (bool, error)

SimPaused reports whether the simulation is paused.

Tps

Go
func Tps(windowSeconds int32) (float64, error)

Tps is the ticks per second over the last windowSeconds. A negative answer, which the host gives before it has measured anything, is an error and not a rate.

  • Parameters:
    • windowSeconds : int32
  • Return type: (float64, error)
  • Slots: get_tps

Mspt

Go
func Mspt(windowSeconds int32) (float64, error)

Mspt is the milliseconds per tick over the last windowSeconds, with Tps's rule.

  • Parameters:
    • windowSeconds : int32
  • Return type: (float64, error)
  • Slots: get_mspt

Env

Go
func Env(name string) (string, error)

Env reads an environment variable of the server process.

  • Parameters:
    • name : string
  • Return type: (string, error)
  • Slots: sys_get_env

SetEnv

Go
func SetEnv(name, value string) error

SetEnv sets an environment variable of the server process.

  • Parameters:
    • name : string
    • value : string
  • Return type: error
  • Slots: sys_set_env

SetTickFreeze

Go
func SetTickFreeze(on bool) error

SetTickFreeze freezes or unfreezes the world.

  • Parameters:
    • on : bool
  • Return type: error
  • Slots: tick_freeze

StepTicks

Go
func StepTicks(n uint32) error

StepTicks lets n more frames through while the world is frozen.

  • Parameters:
    • n : uint32
  • Return type: error
  • Slots: tick_step

SetTickWarp

Go
func SetTickWarp(factor float64) error

SetTickWarp sets the time warp: 0 < factor <= 100, below 1 is slow motion and 1 is normal.

  • Parameters:
    • factor : float64
  • Return type: error
  • Slots: tick_warp

BeginProfile

Go
func BeginProfile(ticks uint32) error

BeginProfile opens a sampling window of ticks frames, from 1 to 12000. Only one window is open at a time.

  • Parameters:
    • ticks : uint32
  • Return type: error
  • Slots: profile_begin

TakeProfile

Go
func TakeProfile() (report string, ready bool, err error)

TakeProfile takes the sampling report as SNBT. ready is false while the window is still open or none was armed. The report is handed out once per window.

  • Return type: (report string, ready bool, err error)
  • Slots: profile_take

IsWine

Go
func IsWine() (bool, error)

IsWine reports whether this host runs under Wine.

ModsRoot

Go
func ModsRoot() (string, error)

ModsRoot returns the mods root directory path where LeviLamina loads mods from. This is typically "C:\BDS\mods" on Windows. Mods can use this to construct paths to their own directories instead of hardcoding "plugins/" or "mods/".

LoadedMods

Go
func LoadedMods() ([]LoadedMod, error)

LoadedMods lists all currently loaded Pier mods with their name, version, and directory.

ServerBdsVersion

Go
func ServerBdsVersion() (string, error)

ServerBdsVersion reads PIER_SRV_BDS_VERSION: Common::getGameVersionString

ServerProtocolVersion

Go
func ServerProtocolVersion() (string, error)

ServerProtocolVersion reads PIER_SRV_PROTOCOL_VERSION: LevelData::mNetworkVersion: the protocol the level was last written by. Says how old the save is, not what the server speaks.

ServerLevelProtocolVersion

Go
func ServerLevelProtocolVersion() (string, error)

ServerLevelProtocolVersion reads PIER_SRV_LEVEL_PROTOCOL_VERSION: "major.minor.patch" of the running build, from CurrentGameSemVersion. Lets a mod carry its own version→protocol table instead of waiting for a Pier release.

ServerGameSemVersion

Go
func ServerGameSemVersion() (string, error)

ServerGameSemVersion reads PIER_SRV_GAME_SEM_VERSION: PIER_SRV_GAME_SEM_VERSION

ServerLoaderVersion

Go
func ServerLoaderVersion() (string, error)

ServerLoaderVersion reads PIER_SRV_LOADER_VERSION: ll::getLoaderVersion, the running LeviLamina

ServerLevelName

Go
func ServerLevelName() (string, error)

ServerLevelName reads PIER_SRV_LEVEL_NAME: LevelData::mLevelName, the world name

ServerIsHardcore

Go
func ServerIsHardcore() (string, error)

ServerIsHardcore reads PIER_SRV_IS_HARDCORE: LevelData::mIsHardcore, "1" or "0"

ServerWorldStartCount

Go
func ServerWorldStartCount() (string, error)

ServerWorldStartCount reads PIER_SRV_WORLD_START_COUNT: LevelData::mWorldStartCount, how many times the world was opened

ServerEducationFeatures

Go
func ServerEducationFeatures() (string, error)

ServerEducationFeatures reads PIER_SRV_EDUCATION_FEATURES: LevelData::mEducationFeaturesEnabled, "1" or "0"

SystemOsName

Go
func SystemOsName() (string, error)

SystemOsName reads PIER_SYS_OS_NAME: sys_utils::getSystemName

SystemOsVersion

Go
func SystemOsVersion() (string, error)

SystemOsVersion reads PIER_SYS_OS_VERSION: sys_utils::getSystemVersion → string

SystemLocale

Go
func SystemLocale() (string, error)

SystemLocale reads PIER_SYS_LOCALE: sys_utils::getSystemLocaleCode

SystemLocalTime

Go
func SystemLocalTime() (string, error)

SystemLocalTime reads PIER_SYS_LOCAL_TIME: sys_utils::getLocalTime → SNBT {year,month,day,hour,minute,second,ms}

SystemProcessId

Go
func SystemProcessId() (string, error)

SystemProcessId reads PIER_SYS_PROCESS_ID: the id of the server process

Srv*

Name Value Description
SrvBdsVersion 0 SrvBdsVersion is PIER_SRV_BDS_VERSION: Common::getGameVersionString
SrvProtocolVersion 1 SrvProtocolVersion is PIER_SRV_PROTOCOL_VERSION: LevelData::mNetworkVersion: the protocol the level was last written by. Says how old the save is, not what the server speaks.
SrvLevelProtocolVersion 2 SrvLevelProtocolVersion is PIER_SRV_LEVEL_PROTOCOL_VERSION: "major.minor.patch" of the running build, from CurrentGameSemVersion. Lets a mod carry its own version→protocol table instead of waiting for a Pier release.
SrvGameSemVersion 3 SrvGameSemVersion is PIER_SRV_GAME_SEM_VERSION: PIER_SRV_GAME_SEM_VERSION
SrvLoaderVersion 4 SrvLoaderVersion is PIER_SRV_LOADER_VERSION: ll::getLoaderVersion, the running LeviLamina
SrvLevelName 5 SrvLevelName is PIER_SRV_LEVEL_NAME: LevelData::mLevelName, the world name
SrvIsHardcore 6 SrvIsHardcore is PIER_SRV_IS_HARDCORE: LevelData::mIsHardcore, "1" or "0"
SrvWorldStartCount 7 SrvWorldStartCount is PIER_SRV_WORLD_START_COUNT: LevelData::mWorldStartCount, how many times the world was opened
SrvEducationFeatures 8 SrvEducationFeatures is PIER_SRV_EDUCATION_FEATURES: LevelData::mEducationFeaturesEnabled, "1" or "0"

Sys*

Name Value Description
SysOsName 0 SysOsName is PIER_SYS_OS_NAME: sys_utils::getSystemName
SysOsVersion 1 SysOsVersion is PIER_SYS_OS_VERSION: sys_utils::getSystemVersion → string
SysLocale 2 SysLocale is PIER_SYS_LOCALE: sys_utils::getSystemLocaleCode
SysLocalTime 3 SysLocalTime is PIER_SYS_LOCAL_TIME: sys_utils::getLocalTime → SNBT
SysProcessId 4 SysProcessId is PIER_SYS_PROCESS_ID: the id of the server process