lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


> And several entities use this script file, so I create a new 
> copy of this table for each of them. I'll probably be 
> generating names for these new tables based on entity ID or 
> something like that, so now I have the following tables: 

My solution is to have each scriptable entity create (from C) a table,
and call a Lua initialization routine with this new table as a parameter.
This function looks like:

function InitMonkey(table)
  table.on_hit=function(monkey)
    PlaySound("squeak")
  end
  -- and so on, you have a lot of predefined responses in global
  -- functions which you then assign to various table.<foo>
end

-- 
Vincent Penquerc'h