Level Editor/Scripting/Map entities: Difference between revisions

From TeamSpec Wiki
Jump to navigation Jump to search
Level Editor: map entities in gamemode scripts
 
American spelling
 
Line 38: Line 38:
* [[Level Editor/Scripting/Reference/GamemodeServerApi#markers|api.markers()]]: every marker's name, in map order.
* [[Level Editor/Scripting/Reference/GamemodeServerApi#markers|api.markers()]]: every marker's name, in map order.
* [[Level Editor/Scripting/Reference/GamemodeServerApi#marker|api.marker(name)]]: where it stands (the origin, and a line in the log, for a name the map does not place).
* [[Level Editor/Scripting/Reference/GamemodeServerApi#marker|api.marker(name)]]: where it stands (the origin, and a line in the log, for a name the map does not place).
* [[Level Editor/Scripting/Reference/GamemodeServerApi#marker_facing|api.marker_facing(name)]]: the way it faces, level and one metre long. A point it looks at is <code>api.marker(n) + api.marker_facing(n) * distance</code>.
* [[Level Editor/Scripting/Reference/GamemodeServerApi#marker_facing|api.marker_facing(name)]]: the way it faces, level and one meter long. A point it looks at is <code>api.marker(n) + api.marker_facing(n) * distance</code>.


== Switchable parts ==
== Switchable parts ==
Line 61: Line 61:
== The map's own bots ==
== The map's own bots ==
Bots that belong to the map are fixtures such as training dummies, not stand-ins for players: nobody can kick them, and they take no player's seat.
Bots that belong to the map are fixtures such as training dummies, not stand-ins for players: nobody can kick them, and they take no player's seat.
* [[Level Editor/Scripting/Reference/GamemodeServerApi#spawn_bot|api.spawn_bot]] spawns one with a name, loadout and team; [[Level Editor/Scripting/Reference/GamemodeServerApi#map_bots|api.map_bots()]] and [[Level Editor/Scripting/Reference/GamemodeServerApi#is_map_bot|api.is_map_bot]] list and recognise them.
* [[Level Editor/Scripting/Reference/GamemodeServerApi#spawn_bot|api.spawn_bot]] spawns one with a name, loadout and team; [[Level Editor/Scripting/Reference/GamemodeServerApi#map_bots|api.map_bots()]] and [[Level Editor/Scripting/Reference/GamemodeServerApi#is_map_bot|api.is_map_bot]] list and recognize them.
* Training orders: [[Level Editor/Scripting/Reference/GamemodeServerApi#bot_idle|api.bot_idle]] (stand still, never shoot), [[Level Editor/Scripting/Reference/GamemodeServerApi#bot_dodge|api.bot_dodge]] (a moving target), [[Level Editor/Scripting/Reference/GamemodeServerApi#bot_shoot|api.bot_shoot]] (fire at one player only).
* Training orders: [[Level Editor/Scripting/Reference/GamemodeServerApi#bot_idle|api.bot_idle]] (stand still, never shoot), [[Level Editor/Scripting/Reference/GamemodeServerApi#bot_dodge|api.bot_dodge]] (a moving target), [[Level Editor/Scripting/Reference/GamemodeServerApi#bot_shoot|api.bot_shoot]] (fire at one player only).
* [[Level Editor/Scripting/Reference/GamemodeServerApi#bot_build|api.bot_build]], [[Level Editor/Scripting/Reference/GamemodeServerApi#bot_demolish|bot_demolish]] and [[Level Editor/Scripting/Reference/GamemodeServerApi#bot_has_building|bot_has_building]]: buildings for a map bot that holds a building tool.
* [[Level Editor/Scripting/Reference/GamemodeServerApi#bot_build|api.bot_build]], [[Level Editor/Scripting/Reference/GamemodeServerApi#bot_demolish|bot_demolish]] and [[Level Editor/Scripting/Reference/GamemodeServerApi#bot_has_building|bot_has_building]]: buildings for a map bot that holds a building tool.

Latest revision as of 04:44, 20 October 2026

Besides zones, pickups and payload tracks, a server script can read and drive the other things a map places: doors, logic entities, map markers, switchable parts and bosses. It can also put up buildings and spawn bots of the map's own. Each of these is found by the name you give it in the editor. Everything here is on the server's GamemodeServerApi.

Doors

A door is named by its name in the scene tree.

A setup time that keeps the attackers' gate shut for the first 60 seconds:

const SETUP_SECONDS := 60.0

var _clock: float = 0.0


func _start() -> void:
	api.door_lock(&"Gate")


func _tick(delta: float) -> void:
	_clock += delta
	if _clock >= SETUP_SECONDS and api.door_locked(&"Gate"):
		api.door_unlock(&"Gate")
		api.door_open(&"Gate")

Outputs and logic

  • api.fire_input(target, input, parameter, delay): send an input to every entity named target, as an output would. parameter is text ("5"); delay is in seconds. False, with a line in the log, for a name the map does not have.
  • api.counter_value(name): a Logic Counter's value.
  • _logic_event(entity, event, activator): a relay, timer, counter or button raised an event ("OnTrigger", "OnTimer", "OutValue", "OnHitMin", "OnHitMax", "OnPressed" or "OnUseLocked"). activator is the player who set it off, 0 for nobody. Its outputs fire either way; this is where a mode reacts to a button press or a counter filling up.

See Outputs and logic.

Map markers

A Map Marker is a named spot and facing.

  • api.markers(): every marker's name, in map order.
  • api.marker(name): where it stands (the origin, and a line in the log, for a name the map does not place).
  • api.marker_facing(name): the way it faces, level and one meter long. A point it looks at is api.marker(n) + api.marker_facing(n) * distance.

Switchable parts

A group with Switchable ticked is a part: everything in it comes and goes together.

Bosses

A Boss Spawn places a boss. Bosses stand whether or not the mode mentions them.

Buildings

The map's own bots

Bots that belong to the map are fixtures such as training dummies, not stand-ins for players: nobody can kick them, and they take no player's seat.

Tile maps

api.open_tile_map opens a grid plan on a player's screen for them to fill in (where to put sentries or walls, say), and _form_submitted(entity_id, form, values) hears what they applied. A player can apply the same map again, so make applying it twice harmless.

Related pages

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