Logic script: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
No edit summary
(Cleaned up and made it less L4D2 specialized)
Line 1: Line 1:
{{sq}}{{l4d2}} {{portal2}}  '''logic_scipt''' is a point entity available in [[Portal 2]] and [[Left 4 Dead 2]]. It is an entity that acts as a container for [[VScript]]. For example, the entity is used extensively with [[L4D2 Vscripts|vscripts]] for the logic in "carnival games" found in the Dark Carnival campaign--''Peanut Gallery'', ''Strongman Contest'', ''Whack-a-Stach'', etc.
{{sq}} {{base point multi|logic_script|game1=Left 4 Dead 2|game2=Alien Swarm|game3=Portal 2}}
 
== Entity description ==
A container for [[VScript|scripts]]. In Left 4 Dead 2, for example, this entity is used extensively for the logic in "carnival games" found in the Dark Carnival campaign, such as ''Peanut Gallery'', ''Strongman Contest'', ''Whack-a-Stach'', etc.


==KeyValues==
==KeyValues==
 
{{KV|EntityGroup[0]|to=EntityGroup[15]|target_destination|Entities to add in the EntityGroup array for the script.}}
;EntityGroup[0-15] Group00-Group15 <code><[[targetname]]></code>
{{Note|The array can be extended beyond 16 entities. Simply add additional EntityGroup## keys with SmartEdit turned off.}}  
:<target_destination>
{{Note|The array can be extended beyond 16 entities. Simply add additional Group## keys with SmartEdit turned off.}}  
{{KV Targetname}}
{{KV Targetname}}


===Additional KeyValues===
== Inputs ==
These additional keys can to be added to the entity with SmartEdit turned off.
;vscripts <code><[[string]]></code>
:Name(s) of script files that are executed after all entities have spawned. The location of the vscript, starting at '''scripts/vscripts'''. Example: carnival_games/gallery_copy_rotators\
;thinkfunction <code><[[string]]></code>
:Name of a function in this entity's script scope which will be called automatically. In L4D2, this allows a function specified to be called every 100 milliseconds (ten times a second) for the duration of the script. You tell it which function to call by adding a thinkfunction key value in your logic_script, setting the value to the name of the function. Valve uses "Think" as the name of the function for their "carnival games". You don't want to do much in this function if it takes more than a 100 milliseconds as it may cause issues.
 
==Inputs==
 
{{I Targetname}}
{{I Targetname}}


==Outputs==
== Outputs ==
 
{{O Targetname}}
{{O Targetname}}
{{DISPLAYTITLE:logic_script}}


==See also==
==See also==
*[[L4D2 Vscripts]]
* [[L4D2 Vscripts]]
*[[Trigger_finale|trigger_finale]]
* [[Left 4 Dead 2 Tool Updates]]
*[[Info_director|info_director]]
* [[Trigger_finale|trigger_finale]]
*[[Left_4_Dead_2_Tool_Updates|Left 4 Dead 2 Tool Updates]]


==External links==
==External links==
*[http://forums.steampowered.com/forums/showthread.php?t=1238461 It's the vscript'ing documentation FAQ! (Steam Forums)]
* [http://forums.steampowered.com/forums/showthread.php?t=1238461 It's the vscript'ing documentation FAQ! (Steam Forums)]
*[http://forums.steampowered.com/forums/showthread.php?t=1242468 Tutorial - Writing a Mini Game - Tic Tac Toe - Part One (Steam Forums)] - An excellent scripting example that uses logic_script to create a tic-tac-toe game with a difficult AI.

Revision as of 01:40, 10 June 2011

Squirrel Template:Base point multi

Entity description

A container for scripts. In Left 4 Dead 2, for example, this entity is used extensively for the logic in "carnival games" found in the Dark Carnival campaign, such as Peanut Gallery, Strongman Contest, Whack-a-Stach, etc.

KeyValues

EntityGroup[0] ([todo internal name (i)]) to EntityGroup[15] <targetname>
Entities to add in the EntityGroup array for the script.
Note.pngNote:The array can be extended beyond 16 entities. Simply add additional EntityGroup## keys with SmartEdit turned off.
Name (targetname) <string>[ Edit ]
The name that other entities refer to this entity by, via Inputs/Outputs or other keyvalues (e.g. parentname or target).
Also displayed in Hammer's 2D views and Entity Report.
See also:  Generic Keyvalues, Inputs and Outputs available to all entities

Inputs

Outputs

See also

External links