API RegisterEvent
From Vendetta Lua
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>