[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Calling a specific function
- From: Tim Conkling <Timothy_Conkling@...>
- Date: Wed, 10 Jul 2002 20:30:37 -0400
I plan on writing an event system for my game whereby different a lua script
attached to an object will register different handlers for events that are
to be handled by the object's script file.
For example, I might have an object of type MyObject, which could be
associated with a file (on disk) called MyObject.lua. When this object was
being created, I would read in MyObject.lua and call a specific function in
that source file such as "initialize()". This function might request that a
function "beep_loudly()" be called for the event "TOUCHED", and the function
"become_invisible()" be called for the event "TIMER_EXPIRED". All of this
function registration has to happen at runtime, of course. How do I handle
calling a specific registered Lua function (in a buffered file) in C, and
how would the function registration work in Lua?