TriggerEvent: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
Line 1: Line 1:
[[Category:Incomplete]]
__NOTOC__  
__NOTOC__  
This fake function is for use with blah & blah and does blahblahblabhalbhl
{{Needs Checking|What does this return?|eAi}}
This function will trigger a named [[event]] on a specific [[element]] in the [[element tree]]. See [[event system]] for more information on how the event system works.


==Syntax==  
==Syntax==  
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
bool triggerEvent ( string name, element element, [ var argument1, var argument2, ... ] )     
bool triggerEvent ( string eventName, element baseElement, [ var argument1, ... ] )     
</syntaxhighlight>  
</syntaxhighlight>  


===Required Arguments===  
===Required Arguments===  
*'''argumentName:''' description
*'''eventName:''' The name of the event you wish to trigger
*'''baseElement:''' The element you wish to trigger the event on. See [[event system]] for information on how this works.


===Optional Arguments===  
===Optional Arguments===  
{{OptionalArg}}  
{{OptionalArg}}  
*'''argumentName2:''' descriptiona
*'''argument1:''' The arguments that the event handler expects should be added after the ''baseElement'' variable.
*'''argumentName3:''' description


===Returns===
===Returns===
Returns ''true'' if blah, ''false'' otherwise.
 


==Example==  
==Example==  
This example does...
If you define a new custom event as follows:
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
--This line does...
-- Get the root map element
blabhalbalhb --abababa
rootElement = getRootElement ()
--This line does this...
 
mooo
-- Add a new event called onSpecialEvent
addEvent ( "onSpecialEvent", "text" )
 
-- Add an event handler
addEventHandler ( "onSpecialEvent", rootElement, "specialEventHandler" )
-- Define our handler function
function specialEventHandler ( text )
outputChatBox ( text )
end
</syntaxhighlight>
 
You can then trigger this event later on using:
<syntaxhighlight lang="lua">
triggerEvent ( "onSpecialEvent", rootElement, "test" )
</syntaxhighlight>
</syntaxhighlight>


==See Also==
==See Also==
{{Event_functions}}
{{Event_functions}}
[[Category:Incomplete]]

Revision as of 23:30, 20 May 2006


Dialog-information.png This article needs checking.

Reason(s): What does this return?

This function will trigger a named event on a specific element in the element tree. See event system for more information on how the event system works.

Syntax

bool triggerEvent ( string eventName, element baseElement, [ var argument1, ... ] )    

Required Arguments

  • eventName: The name of the event you wish to trigger
  • baseElement: The element you wish to trigger the event on. See event system for information on how this works.

Optional Arguments

NOTE: When using optional arguments, you might need to supply all arguments before the one you wish to use. For more information on optional arguments, see optional arguments.

  • argument1: The arguments that the event handler expects should be added after the baseElement variable.

Returns

Example

If you define a new custom event as follows:

-- Get the root map element
rootElement = getRootElement ()

-- Add a new event called onSpecialEvent
addEvent ( "onSpecialEvent", "text" )

-- Add an event handler
addEventHandler ( "onSpecialEvent", rootElement, "specialEventHandler" )
-- Define our handler function
function specialEventHandler ( text )
	outputChatBox ( text )
end

You can then trigger this event later on using:

	triggerEvent ( "onSpecialEvent", rootElement, "test" )

See Also