[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: How do I check for errors returned from a C function?
- From: John Klimek <jklimek@...>
- Date: Fri, 30 Dec 2005 10:05:06 -0500
For my game I plan to have lots of objects running scripts (players,
npcs, rooms, items, etc). Whenever an object runs a script I create a
global lua userdata called "Entity". The lua script can then check
for the actual entity type by using Entity:GetType.
Now suppose that only player entities can use the SendText C function.
The following code would be invalid:
if (Entity:GetType() == 'item') then
Entity:SendText("Hello!"); // invalid, item Entity's cannot use SendText
end;
So what I'd like to do is for the C function SendText is throw back an
error. I'm aware that I can push the error message to the stack and
then use lua_error but how do I check for the error inside of my lua
script?
Also, does my above script engine logic seem OK?