Point script use target: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
(Created page with "{{l4d2 point|point_script_use_target}} It makes an other entity behave like a button similar to func_button_timed. The entity is intended to be programmed from an attached [[...")
 
mNo edit summary
Line 1: Line 1:
{{l4d2 point|point_script_use_target}} It makes an other entity behave like a button similar to [[func_button_timed]]. The entity is intended to be programmed from an attached [[L4D2_Vscripts|VScript]] instead of using Hammer, and calls hook functions in its own scripting scope as well as normal entity outputs. It is mainly used for run-time created [[L4D2_EMS/Appendix:_Spawning|entity groups]] together with a use target script based on <code>base_buildable.nut</code>.  
{{l4d2 point|point_script_use_target}} It makes an other entity behave like a button similar to [[func_button_timed]]. The entity is intended to be programmed from an attached [[L4D2_Vscripts|VScript]] instead of using Hammer, and calls hook functions in its own scripting scope as well as normal entity outputs. It is mainly used for run-time created [[L4D2_EMS/Appendix:_Spawning|entity groups]] together with a use target script based on <code>usetargets\base_buildable_target.nut</code>.  


See the scripts in <code>left 4 dead 2\sdk_content\scripting\scripts\vscripts\</code> for examples of use.
See the scripts in <code>left 4 dead 2\sdk_content\scripting\scripts\vscripts\</code> for examples of use.

Revision as of 13:10, 19 April 2014

Template:L4d2 point It makes an other entity behave like a button similar to func_button_timed. The entity is intended to be programmed from an attached VScript instead of using Hammer, and calls hook functions in its own scripting scope as well as normal entity outputs. It is mainly used for run-time created entity groups together with a use target script based on usetargets\base_buildable_target.nut.

See the scripts in left 4 dead 2\sdk_content\scripting\scripts\vscripts\ for examples of use.

Game engine hooks

These VScript methods are called by the entity on the script set in the Entity Scripts keyvalue.

Function Signature Description
OnUseFinished void OnUseFinished() Called when the player has used this button for at least 'FinishTime' seconds.
OnUseStart bool OnUseStart() Called when the player begins to use this button. Return false to stop the player from using the button.
OnUseStop void OnUseStop(float timeUsed) Called when the player stops using this button. Passes the time this button has been used (time between StartUse and now).
Precache void Precache() Called by the game engine when the entity first spawns, immediately after this script is run.

Script methods

These VScript methods can be called from the script, using the self handle. The methods for CBaseEntity are also available.

Function Signature Description
CanShowBuildPanel void self.CanShowBuildPanel(bool showPanel) Sets if the UI panel for the button is shown.
GetUseModelName string self.GetUseModelName() Get the entity name of the prop bound to this button.
SetProgressBarText void self.SetProgressBarText(string text) Sets the use text for the button UI.
SetProgressBarSubText void self.SetProgressBarText(string text) Sets the subtext below the progress bar for the button UI.
SetProgressBarFinishTime void self.SetProgressBarFinishTime(float time) Sets the total time the button takes to use.
SetProgressBarCurrentProgress void self.SetProgressBarCurrentProgress(float time) Sets the current use progress. It can be used to save the use progress when the user releases the use key.
StopUse void self.StopUse() Prevents players from using the button.

Keyvalues

Use Model ([todo internal name (i)]) <targetname>
The name of the entity the player will be using.


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

Origin:

Origin (X Y Z) (origin) <origin>
The position of this entity's center in the world. Rotating entities typically rotate around their origin.

Inputs

Outputs

OnUseStarted
Fired when a player starts using this target.
OnUseCanceled
Fired when a player use is canceled.
OnUseFinished
Fired when a player use is complete.