I was using that in synced code. Problem is, it's not working
it is impossible to access static-var's
First off, thank you very much, for giving me more information about this issue, this is driving me nuts.
Unfortunately, I still don't see the result here.
In my LUA script, I have the following line:
Code: Select all
local Y1 = Spring.GetUnitCOBValue(u,1,piece)/COBSCALE
That means that value 1024 is what we're trying to GET, right? What is "piece", though? That part doesn't make any sense- I'm not trying to get a piece, I'm trying to get a value of a variable. Or, are you saying that this gets a Piece coordinate only? I tried a value of (u,1,1) to test that assumption, and that's obviously not right- it wasn't returning the height value of the relevant Piece, even on ground units.
It always returns a value of 1 for the variable.
So, to test further, in my script, I tried setting value 1024 to a specific value, on the COB side:
The resulting return from COB was 1

If this is a Piece coordinate, it doesn't make sense.
Moreover, there aren't any other commands in LUA for operating with COB data sending over packed coordinates, which is the real problem here. If I could just send the data as args, and unpack it, I'd be done with this. However, unpacking it in LUA manually is incredibly CPU intensive, I don't want to do that.
All I want to do here is to have LUA fetch some data, unpack it in C++, and then do an operation on it.
I need to do this a lot, if I'm going to do stuff like new special FX that use Piece positions to determine where to put vertices... I got quads drawing with textures just fine, I just need this last part, then I'll happily give User my code, and we'll have quad-based, textured trails that emanate from engines / wingtips, for but that's just a start.
I've been looking over the FX from Dawn of War, and I am certain that if User's code is as good as it looks like, then by combining COB data and LUA's access to OpenGL, we're going to be able to do some amazing stuff, totally changing our FX and making our previous FX look like crap. This is very exciting to me, as I'm pretty much hitting wall after wall, in terms of what I want FX to do- I have a lot of ideas that will use something other than CEG, or CEG-like behavior, and they rely on using COB to pass LUA data to speed stuff up, which is looking very attractive now that I'm getting the hang of working with OpenGL and LUA a little bit.
Hmm...
looking here...
Code: Select all
const int result = unit->cob->GetUnitVal(val, p[0], p[1], p[2], p[3]);
Um, that's returning an array, correct? Why? We just want a single value to come back, we're not running a COB script and returning arguments...