VERGELua API

world

Trace, playerlist, gamerules: world queries and round state.

trace

trace.Line(start:Vector3, end:Vector3, mask?:number):Trace

Ray trace a line from start to end.

trace.Hull(start:Vector3, end:Vector3, mins:Vector3, maxs:Vector3, mask?:number):Trace

Box trace (hull) from start to end; mask defaults to MASK_SOLID.

playerlist

playerlist.IsFriend(ent:Entity):boolean

Whether the entity is marked as a friend.

playerlist.IsPriority(ent:Entity):boolean

Whether the entity has a priority tag.

playerlist.InParty(ent:Entity):boolean

Whether the entity is in the party.

playerlist.IsF2P(ent:Entity):boolean

Whether the entity is free-to-play.

playerlist.GetPriority(target:Entity|number|string):number

Priority tag of an entity, userID, or SteamID; 0 when none.

playerlist.SetPriority(target:Entity|number|string, priority:number):boolean

Assign an assignable priority tag; false when unavailable.

playerlist.GetColor(target:Entity|number|string):number

Packed ARGB tag color of an entity, userID, or SteamID; nil when unknown.

gamerules

gamerules.GetRoundState():number

Current round state.

gamerules.GetWinningTeam():number

Team number of the round winner.

gamerules.IsTruceActive():boolean

Whether a truce is active.

gamerules.IsCompetitive():boolean

Whether competitive mode is enabled.

gamerules.IsMannVsMachine():boolean

Whether a Mann vs. Machine game is being played.

gamerules.IsMatchmaking():boolean

Whether in a matchmaking game.

gamerules.IsInSetup():boolean

Whether the round is in setup time.

gamerules.IsInOvertime():boolean

Whether the round is in overtime.

gamerules.IsMatchEnded():boolean

Whether the match has ended.

gamerules.IsInWaitingForPlayers():boolean

Whether waiting for players before a round.

gamerules.GetGameType():number

Current game type.

gamerules.GetMatchGroupType():number

Current match group type.

gamerules.GetWinReason():number

Reason the round was won.

gamerules.IsMatchTypeCasual():boolean

Whether the match group is casual.

gamerules.IsMatchTypeCompetitive():boolean

Whether the match group is competitive.

gamerules.IsManagedMatchEnded():boolean

Whether the match has ended; alias of IsMatchEnded.

gamerules.IsMvM():boolean

Whether a Mann vs. Machine game is being played; alias of IsMannVsMachine.

gamerules.GetCurrentMatchGroup():number

Current match group.

gamerules.GetTimeLeftInMatch():number

Countdown timer value in seconds; the closest live round clock.

gamerules.IsUsingSpells():boolean

Whether Halloween spells are enabled.

gamerules.IsUsingGrapplingHook():boolean

Whether the local player has a grappling hook target.

objectives

objectives.GetControlPoints(team?:number):table

Control points as {index, owner, locked, canCap, position} array; pass team to include canCap.

objectives.GetCartPosition():Vector3

Payload cart origin, or nil when no cart exists.

Examples

Round state + line of sight

Prints the round state, payload cart position and the wall in front of you once per second.

local last = 0

callbacks.Register("CreateMove", function()
    local tick = globals.TickCount()
    if tick - last < 66 then return end
    last = tick

    local running = gamerules.GetRoundState() == E_RoundState.ROUND_RUNNING
    print(string.format("round running=%s setup=%s", tostring(running), tostring(gamerules.IsInSetup())))

    local cart = objectives.GetCartPosition()
    if cart then
        print(string.format("cart at %.0f,%.0f,%.0f", cart.x, cart.y, cart.z))
    end

    local me = client.GetLocalPlayer()
    if me:IsValid() then
        local eye = me:GetEyePosition()
        local fwd = vector.AngleForward(client.GetViewAngles())
        local tr = trace.Line(eye, eye + vector.Multiply(fwd, 2000))
        print(string.format("wall ahead at %.0f%%", tr.fraction * 100))
    end
end)