Originally Posted by
savage
I hope I deleted the right one.
Thanks savage, yes you did delete the correct one
BTW, I have made another small change to the code.
I have renamed the 'LuaVector3fCheck' function to 'LuaRecordCheck' and am now passing in the RecordName into the function as well to make it a generic LuaRecord checking function.
I then moved it to the LuaRecords unit along with the appropriate interface header for the function.
So you have to change rename the function, make the small code changes to it, move it to the LuaRecords unit and change all references of 'LuaVector3fCheck' in the example code to 'LuaRecordCheck' and add in the 'Vector3f' parameter when using it (substitute for the correct record name when using it for other LuaRecord types like so:
Code:
V3f := LuaRecordCheck(L,'Vector3f',1);
New LuaRecordCheck function now in the LuaRecords unit
Code:
Function LuaRecordCheck(L: lua_State; RecordName: AnsiString; Idx: Integer): Pointer;
Begin
Result := Nil;
If (Not lua_istable(L,Idx)) Then
Begin
LuaDoError(L,RecordName + ' expected, found "'+lua_typename(L,lua_type(L,Idx))+'"');
Exit;
End;
lua_getmetatable(L,Idx);
lua_pushstring(L,PChar('_' + RecordName));
lua_gettable(L,-2);
If (Not lua_isuserdata(L,-1)) Then
Begin
LuaDoError(L,RecordName + ' expected, found "'+lua_typename(L,lua_type(L,Idx))+'"');
Exit;
End;
Result := lua_touserdata(L,-1);
End;
Enjoy
cheers,
Paul.
Bookmarks