Level Editor/Scripting/Client HUD

From TeamSpec Wiki
Jump to navigation Jump to search

client.gd draws your mode. It starts with extends GamemodeClientScript and runs on every player's machine, so it can read and show but never change anything: its api, a GamemodeClientApi, has no way to write. Its hooks are on GamemodeClientScript.

What it can read

Hooks

  • _start(): the server's counters have arrived. Put your widgets on screen here.
  • _counter_changed(scope, key, name, value): a counter changed. scope is api.SCOPE_PLAYER, api.SCOPE_TEAM or api.SCOPE_GLOBAL; key is the player's entity id, the team, or 0 for a global counter. Widgets update by themselves, so you only need this hook for something of your own.
  • _match_ended(team): the round is decided. team is the winner, or 0 for a draw.

Widgets

api.show_widget puts one of TeamSpec's HUD widgets on screen and returns a handle for api.remove_widget. You name the widget and hand it a Dictionary of settings; counter names can be written as plain strings. A widget opens showing the current values and keeps itself up to date, so there is nothing to call every frame. A name that is not one of the five below shows nothing.

func _start() -> void:
	api.show_widget(&"team_score", {
		"counter": "score",
		"threshold": api.counter_maximum(api.SCOPE_TEAM, &"score"),
	})

team_score

Every team's value of one team counter, side by side in team order, followed by the goal. Teams 1 and 2 have their own colors.

  • counter: the team counter to show.
  • threshold: the winning number, shown after the scores. 0 hides it.
  • warn_at: highlight a team's number once it reaches this. 0 means never.

carry_pips

A row of pips for one player counter, for the player the HUD is following: the local player, or whoever they are spectating.

  • counter: the player counter to show.
  • maximum: how many pips to draw.
  • label: optional text beside the row.

round_timer

A clock showing minutes and seconds left.

  • counter: a global counter holding the seconds left.
  • warn_at: at or under this many seconds the clock takes its warning look. 0 means never.
  • setup: optional global counter; while it is not 0 the clock shows SETUP.
  • overtime: optional global counter; while it is not 0 the clock shows OVERTIME instead of the time.

payload_progress

A bar the cart marker rides along, with a pip per checkpoint.

  • counter: a global counter holding how far the cart has come, from 0 to scale.
  • scale: that counter's value at the end of the track.
  • checkpoints: an Array of each checkpoint's position along the bar, from 0 to 1. Divide each of api.track_checkpoints by api.track_length.
  • pushers: optional global counter, shown while above 0.
  • blocked: optional global counter; while it is not 0 the bar shows BLOCKED.
  • rollback: optional global counter; while it is not 0 the bar shows ROLLING BACK.

boss_health

Two bars for a two-team boss mode: the player's own team's boss on the left, the enemy's on the right, each in its team's color, with the share it has left. A boss at 0 shows SLAIN. A player on no team sees team 1 on the left, with the teams' names on the bars.

  • counter: a team counter holding each team's boss's health, from 0 (dead) to scale, keyed by the team the boss belongs to.
  • scale: that counter's value for a boss at full health.
  • warn_at: a living boss at or under this takes the warning look. 0 means never.
  • team_names: a Dictionary of team to name, for a player on no team. Build it from api.teams and api.team_name.

Messages

A client script cannot send messages: it only knows about the person at its own keyboard. Tell a player something from the server instead, with api.notify. See Server rules.

TeamSpec Level Editor
Basics Getting started · Interface · Viewport and camera · Selecting and hiding · Keyboard shortcuts · Settings · Map Config · Troubleshooting
Menus File · Edit · View · Tools · Functional
Panels Scene tree · Inspector · Materials · Props · Snapping · UV editor · Displacement · Terrain
Tools Move, Rotate and Scale · Box · Sphere · Cylinder · Prism · Stairs · Spiral Stairs · Spiral Tower · Arch · Path Brush · Plane · Terrain · Clip · Duplicate · Ruler and Cordon · Edit Vertex and Edge · Edit Face · Loop Cut · Material Brush · Vertex Color Brush · Displacement · Prop Path
Entities Brush · Zone · Group · Mirror Node · Prop · Spawn Point · Supply Pickup · World Boundary · Lights · Water · Sounds · Anchor Platform · Payload Track · Boss Spawn · Map Marker · World Text · Decal · Door · Button · Logic entities · 3D Skybox · Nav Region
Workflows Your first map · Brushes and CSG · Materials and UVs · Lighting and lightmaps · Bots and navigation · Mirrored maps · Outputs and logic · Custom assets · Playtesting · Exporting and publishing · Importing Source maps
Scripting Overview · Server rules · Client HUD · Bots · Teams and spawning · Zones · Pickups · Payload tracks · Map entities · Sandbox limits · Testing · King of the Hill · Team Deathmatch · API reference · What a script may use