<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.teamspec.net/index.php?action=history&amp;feed=atom&amp;title=Level_Editor%2FScripting%2FPickups</id>
	<title>Level Editor/Scripting/Pickups - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.teamspec.net/index.php?action=history&amp;feed=atom&amp;title=Level_Editor%2FScripting%2FPickups"/>
	<link rel="alternate" type="text/html" href="https://wiki.teamspec.net/index.php?title=Level_Editor/Scripting/Pickups&amp;action=history"/>
	<updated>2026-10-29T02:37:13Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.43.11</generator>
	<entry>
		<id>https://wiki.teamspec.net/index.php?title=Level_Editor/Scripting/Pickups&amp;diff=61&amp;oldid=prev</id>
		<title>TeamSpecBot: Level Editor: pickups scripting guide</title>
		<link rel="alternate" type="text/html" href="https://wiki.teamspec.net/index.php?title=Level_Editor/Scripting/Pickups&amp;diff=61&amp;oldid=prev"/>
		<updated>2026-10-20T03:46:21Z</updated>

		<summary type="html">&lt;p&gt;Level Editor: pickups scripting guide&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;Pickups are things on the ground a player collects by walking over them: the level&amp;#039;s own health and ammo packs, and anything a script drops (souls, ammo, health). This page covers both.&lt;br /&gt;
&lt;br /&gt;
== Supply stations ==&lt;br /&gt;
&lt;br /&gt;
A [[Level Editor/Entities/Supply Pickup|Supply Pickup]] from the Functional menu is a health or ammo pack that belongs to the level. Click to place it, then set it in the inspector:&lt;br /&gt;
&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;Pool&amp;#039;&amp;#039;&amp;#039;: health or ammo.&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;Size&amp;#039;&amp;#039;&amp;#039;: small, medium or large. A small pack refills a quarter of the maximum, a medium half, a large all of it.&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;Respawn Seconds&amp;#039;&amp;#039;&amp;#039;: how long after somebody takes the pack the next one appears.&lt;br /&gt;
&lt;br /&gt;
Supply stations work with no script at all. A player who is already full does not take a pack, so it stays for somebody who needs it. To your script a station&amp;#039;s pack is an ordinary pickup: &amp;lt;code&amp;gt;_can_collect&amp;lt;/code&amp;gt; may refuse it and &amp;lt;code&amp;gt;_pickup_collected&amp;lt;/code&amp;gt; hears it taken. Removing one with [[Level Editor/Scripting/Reference/GamemodeServerApi#despawn_pickup|api.despawn_pickup]] does not remove the station; its next pack comes back on the usual timer.&lt;br /&gt;
&lt;br /&gt;
== Dropping pickups from a script ==&lt;br /&gt;
&lt;br /&gt;
[[Level Editor/Scripting/Reference/GamemodeServerApi#spawn_pickup|api.spawn_pickup]]&amp;lt;code&amp;gt;(kind, position, team, lifetime, radius)&amp;lt;/code&amp;gt; puts something on the ground and returns its &amp;#039;&amp;#039;&amp;#039;handle&amp;#039;&amp;#039;&amp;#039;, a number that names it from then on.&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;kind&amp;lt;/code&amp;gt; is one of: &amp;lt;code&amp;gt;soul&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;ammo_small&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;ammo_medium&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;ammo_large&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;health_small&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;health_medium&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;health_large&amp;lt;/code&amp;gt;. A name outside this list shows nothing.&lt;br /&gt;
* The ammo and health kinds refill the player by themselves when collected. A &amp;lt;code&amp;gt;soul&amp;lt;/code&amp;gt; does nothing by itself: it is worth whatever your &amp;lt;code&amp;gt;_pickup_collected&amp;lt;/code&amp;gt; says.&lt;br /&gt;
* &amp;lt;code&amp;gt;team&amp;lt;/code&amp;gt; is whose it is (0 for nobody&amp;#039;s). Nothing reads it but your own &amp;lt;code&amp;gt;_can_collect&amp;lt;/code&amp;gt;.&lt;br /&gt;
* &amp;lt;code&amp;gt;lifetime&amp;lt;/code&amp;gt; is how many seconds it lasts untaken; 0 means it stays until somebody takes it.&lt;br /&gt;
* &amp;lt;code&amp;gt;radius&amp;lt;/code&amp;gt; is how close a player has to come.&lt;br /&gt;
&lt;br /&gt;
The game rests a drop on the floor below the position you give, so it does not hang in the air. To drop several around one spot, as when somebody dies carrying things, use [[Level Editor/Scripting/Reference/GamemodeServerApi#scatter_pickups|api.scatter_pickups]] at [[Level Editor/Scripting/Reference/GamemodeServerApi#death_position|api.death_position]]: it spreads them in a ring and keeps every one of them on the near side of any wall, which a loop of &amp;lt;code&amp;gt;spawn_pickup&amp;lt;/code&amp;gt; cannot do.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
func _player_died(entity_id: int, _killer_id: int, default_seconds: float) -&amp;gt; void:&lt;br /&gt;
	var carried: int = api.get_player(entity_id, &amp;amp;amp;&amp;quot;carrying&amp;quot;)&lt;br /&gt;
	if carried &amp;gt; 0:&lt;br /&gt;
		api.set_player(entity_id, &amp;amp;amp;&amp;quot;carrying&amp;quot;, 0)&lt;br /&gt;
		api.scatter_pickups(&amp;amp;amp;&amp;quot;soul&amp;quot;, api.death_position(), carried, 1.2, api.team_of(entity_id), 30.0)&lt;br /&gt;
	api.respawn_in(entity_id, default_seconds)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Collecting ==&lt;br /&gt;
&lt;br /&gt;
When a living player comes within a pickup&amp;#039;s radius it flies to them, and it is collected when it reaches them.&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;_can_collect(handle, entity_id)&amp;lt;/code&amp;gt; is asked first, and again when it arrives. Return false to refuse; the default allows everyone. Check the kind first, so your rule for souls does not stop players taking ammo:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
func _can_collect(handle: int, entity_id: int) -&amp;gt; bool:&lt;br /&gt;
	if api.pickup_kind(handle) != &amp;amp;amp;&amp;quot;soul&amp;quot;:&lt;br /&gt;
		return true&lt;br /&gt;
	return api.pickup_team(handle) != api.team_of(entity_id)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;_pickup_collected(handle, entity_id)&amp;lt;/code&amp;gt; runs when it has been taken. During this hook the handle still answers [[Level Editor/Scripting/Reference/GamemodeServerApi#pickup_kind|api.pickup_kind]] and [[Level Editor/Scripting/Reference/GamemodeServerApi#pickup_team|api.pickup_team]]; afterwards it is gone.&lt;br /&gt;
* &amp;lt;code&amp;gt;_pickup_expired(handle)&amp;lt;/code&amp;gt; runs when one runs out of lifetime untaken.&lt;br /&gt;
&lt;br /&gt;
[[Level Editor/Scripting/Reference/GamemodeServerApi#pickups|api.pickups]] lists every handle on the ground, and [[Level Editor/Scripting/Reference/GamemodeServerApi#pickup_position|api.pickup_position]] says where one is.&lt;br /&gt;
&lt;br /&gt;
== What every death drops ==&lt;br /&gt;
&lt;br /&gt;
Whatever your mode does, every death drops a medium ammo pack where the player died, which lasts 30 seconds and belongs to nobody.&lt;br /&gt;
&lt;br /&gt;
== Resupply zones ==&lt;br /&gt;
&lt;br /&gt;
To refill players who stand in a zone, call [[Level Editor/Scripting/Reference/GamemodeServerApi#resupply|api.resupply]] from &amp;lt;code&amp;gt;_zone_entered&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;_zone_tick&amp;lt;/code&amp;gt;. See [[Level Editor/Scripting/Teams and spawning#Spawn rooms|Spawn rooms]].&lt;br /&gt;
&lt;br /&gt;
{{Level Editor nav}}&lt;br /&gt;
&lt;br /&gt;
[[Category:Level Editor]]&lt;br /&gt;
[[Category:Gamemode scripting]]&lt;/div&gt;</summary>
		<author><name>TeamSpecBot</name></author>
	</entry>
</feed>