Difference between revisions of "Lua:IsGrenade"
From Fortress Forever Wiki
Jump to navigationJump to searchMulchman MM (talk | contribs) |
Mulchman MM (talk | contribs) |
||
| Line 13: | Line 13: | ||
===Example=== | ===Example=== | ||
| + | Here's an example of giving a team a point whenever a grenade touches a trigger_ff_script named "red_goal": | ||
| + | |||
| + | <pre>-- In the map's .LUA file... | ||
| + | |||
| + | -- Define red_goal trigger_ff_script | ||
| + | red_goal = trigger_ff_script:new({}) | ||
| + | |||
| + | -- When we're touched by a grenade, give the grenade owners team a point | ||
| + | function red_goal:ontouch( ent_id ) | ||
| + | if IsGrenade( ent_id ) then | ||
| + | -- Add 1 point to the grenade owners team | ||
| + | AddTeamScore( GetObjectsTeam( ent_id ), 1 ) | ||
| + | end | ||
| + | end</pre> | ||
| + | |||
| + | ===Important Note=== | ||
| + | If you want trigger's to react to grenades you MUST 'check'/'tick' the "everything" option on the flags tab of the entity in Hammer. | ||
| + | |||
| + | [http://mulchman.trepid.net/tick-everything.JPG Important Note] | ||
[[Category:LUA_Commands]] | [[Category:LUA_Commands]] | ||
Revision as of 06:36, 18 June 2006
IsGrenade
IsGrenade is used to see if an entity index being passed into a function is a grenade or not.
Usage
IsGrenade( ent_id )
Input
The ent_id passed in is simply an integer index that refers to an entities game code ENTINDEX().
Output
The output is true or false depending if ent_id is a grenade or not. A list of grenades can be found here.
Example
Here's an example of giving a team a point whenever a grenade touches a trigger_ff_script named "red_goal":
-- In the map's .LUA file...
-- Define red_goal trigger_ff_script
red_goal = trigger_ff_script:new({})
-- When we're touched by a grenade, give the grenade owners team a point
function red_goal:ontouch( ent_id )
if IsGrenade( ent_id ) then
-- Add 1 point to the grenade owners team
AddTeamScore( GetObjectsTeam( ent_id ), 1 )
end
end
Important Note
If you want trigger's to react to grenades you MUST 'check'/'tick' the "everything" option on the flags tab of the entity in Hammer.