API RegisterEvent

From Vendetta Lua
Revision as of 22:03, 25 January 2009 by Chefkoch (talk | contribs) (split)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search

RegisterEvent

Definition: RegisterEvent({func OnEvent}, string eventtype) -> nil
Description:
hook up object to event. the obect is a table with a method called OnEvent that is called when the event is triggered
Arguments:
OnEvent function to call when event is triggered
eventtype eventtype
Example:
obj = {} -- create method in above created table that prints out the name of the event and the data passed to it function obj:OnEvent(event, ...) print(event) print(...) end -- Register the event RegisterEvent(obj, "TEST_EVENT") -- trigger the event and pass the string "test" to it ProcessEvent("TEST_EVENT", "test") -- which should output: -- TEST_EVENT -- test </source>