MarauderIIC wrote:I don't see why you wouldn't be able to pass a Lua function the target of your weapon.
Couldn't you do something like-
C++:
Code: Select all
Weapon::Fire(Target& target /*or even int targetID*/) {
//Call weapon_fire lua script, passing it targetID
}
?
I don't know enough about LuaBind, or Lua in general, to be able to tell you specifics, but wouldn't not being able to use it like that make it, oh, mostly useless? Maybe Falco can help.
yea using luaBind I'm pretty sure you can pass pointers to existing objects i just don't know how yet.
So I spent some time playing with luaBind and I defiantly like the part about not having to remake set and get function specifically for lua use, also being able to bind entire classes to lua is awesome.
Now I've been reading all the luaBind stuff google brings up but I cant seem to find a simple example of passing a pointer to an already existing object to lua.
Also is there a way to register something like an already existing array or vector of objects so you can do something like
Code: Select all
function shoot(target)
unit[target].Dmg(10)
end
or just do a pointer to an object
Code: Select all
function shoot(Unit* target) --Probably wrong
target.Dmg(10)
end
Another example of needing access to the unit array would be writing a cloaking components script.
In c++ Id just run a for loop checking each enemy ships sensor to see if it can see cloaked ships and if so does its sensor range collide with the cloaked ship,
but to do that in lua Id need access to the unit array.
SideNote I was able to make a very simplified version of that lua console thing you have, and its awsome to be able to type in lua commands in game.Question about your adventure log thing though,
is that log writing everything out to a txt file and storing it all there or do you have some kind of array holding all the strings? I'm considering trying to expand to a full blown console deal like yours but I've never done anything like that so I wasn't sure how to store the logs or whatever.
I will live forever or die trying.
"Human beings didn't evolve brains in order to lie around on lakes. Killing's the first thing we learned. And a good thing we did, or we'd be dead, and the tigers would own the earth."
- Valentine to Ender ("Ender's Game")