lua-users home
lua-l archive

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


> I'm fairly new to Lua.  I've managed to embed it within a game engine and
> also have an API available to it so that the scripts can be used 
> to control
> high level aspects of the game.  However I would like to add a new data
> type: integer, to the language.  I have converted the number type from
> double to float for now, however I still think that a new type that is
> basically a C int is required for my purposes.

Can't you do without float and only int ?
If you can't, I guess you'll have to duplicate a fair amount of code to
deal with both types at a time, as I guess runtime conversion from one
type to the other is not an option, as is already between numbers and
strings.

Alternatively, but I think this is not the type of solution you are looking
for, if you use one of the types seldom, you could put it in userdata,
and attach a specific tag to tose to perform the operations you need on
this type. Because of speed, this solution might be worthwhile only for
seldom used operations.

-- 
Vincent Penquerc'h