Use: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
mNo edit summary
m (added e key info)
Line 1: Line 1:
All entities have a '''Use''' [[input]], though many do nothing in response to it. There are four ways to trigger it:
All entities have a '''Use''' [[input]], though many do nothing in response to it. There are four ways to trigger it:


# A player looking at the entity and invoking the <code>+use</code> command
# A player looking at the entity and invoking the <code>+use</code> command (typically by pressing their '''e''' key)
# An entity firing it via an [[output]]
# An entity firing it via an [[output]]
# An entity firing an output that does not specify an input on the target entity
# An entity firing an output that does not specify an input on the target entity
Line 9: Line 9:


== Programming ==
== Programming ==
Although there is always a Use input, the actual Use function of an entity starts null. It can be assigned at any time with <code>SetUse( void *SomeFunc([[CBaseEntity]] *pActivator, CBaseEntity *pCaller, USE_TYPE useType, [[float]] value) )</code>.
Although there is always a Use input, the actual Use function of an entity starts null. It can be assigned at any time with <code>SetUse( void *SomeFunc([[CBaseEntity]] *pActivator, CBaseEntity *pCaller, USE_TYPE useType, [[float]] value) )</code>.



Revision as of 17:05, 28 May 2018

All entities have a Use input, though many do nothing in response to it. There are four ways to trigger it:

  1. A player looking at the entity and invoking the +use command (typically by pressing their e key)
  2. An entity firing it via an output
  3. An entity firing an output that does not specify an input on the target entity
  4. An entity directly calling the C++ function

Use typically performs the action players most expect when interacting with the entity (e.g. opening/closing a door, picking up a physics object).

Programming

Although there is always a Use input, the actual Use function of an entity starts null. It can be assigned at any time with SetUse( void *SomeFunc(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) ).

It doesn't appear possible to specify USE_TYPE or value through the I/O system.