Lua Lua Lua Lua Lua Lua (not LUA).
See how GMod does it.
Or if you want to make it simple, just pass a table.
(This is not LUA for GMOD)
I am working on a game. I have hit the problem, maybe those more experienced in lua might know what i need. So what's going on:
I have implemented LUA in my c++ project. It works well.
I want to have entities that are created and controlled by lua code. What i have got now is that when lua code is loaded and executed, c++ functions that define the main properties of the entity are called. For now these contain functions like "addProp", "addWeld", "addHinge", "makeMotor" and so on. In the c++ there is an object for every type of entity created, which holds these parameters (called EntDef for example)
then there are LUA functions called every game tick to control the entity. And here's the problem: i made the compiled chunk shared for all entities of one type (means one chunk per EntDef), which works well for definition and creating. Problem is that lua function "Tick" also shares all the lua globals with other entities.
One (and only one i could imagine clearly) solution would be to create separate chunk for every entity created; only problem there is the amount of lua code to compile and store in memory - everything is compiled for every one. Would this be too expensive?
If you have any idea what i am talking about, feel free to help me xD
"see how GMod does it"
Can you send me the source codes?
Another thing - attempts to call "setmetatable" results in error (global setmetatable nil) any ideas? It's built-in function.
Yeah this is the thing that bothers me the most now.
--LOL i had to implement default basic lua function by myself xD looks crappy but works :-P
Last edited by Pangamini; 02-18-2010 at 04:47 PM.
Use gamemonkey, then you don't have to emulate classes or any of that BS.
Anticept - HP you are terrible at trolling. Always have been. Leave it up to the pros like Jat.
Black Phoenix - Actually cunt goes into bullshit. Bullshit does not fit in cunt.
Drunkie - Logically, Jat Goodwin must be a fist pumping guido.
I have no idea what is that gamemonkey, but i have already solved this using metatables
GameMonkey Script
Real classes! Dealing with an object oriented language is usually a better solution, especially in games.
Anticept - HP you are terrible at trolling. Always have been. Leave it up to the pros like Jat.
Black Phoenix - Actually cunt goes into bullshit. Bullshit does not fit in cunt.
Drunkie - Logically, Jat Goodwin must be a fist pumping guido.
It's how you understand lua metatables. If you get them, it can be even more powerful than classes. It's freedom :-P
Bookmarks