Getting Action Points in LUA?
I know you can grab the ho tspot, but it would be great to make functions getting the current frame's action point as well. (For say, creating a bullet at the tip of a gun, when the hot spot is at the trigger.)
Is this available and I missed it?
If not, consider this a request :)
thanks,
Andy
Re: Getting Action Points in LUA?
I'm pretty open to adding interface functions by request, so try this: http://hocuspocus.taloncrossing.com/rii/xlua-dist.zip
Action points are actually much trickier to get (as far as I can see), so let me know if it crashes or otherwise behaves oddly. It will return the action point relative to sprite origin, whereas MMF seems to return them as an absolute coordinate on the frame, so be ready to do some arithmetic if that's what you want.
Added to the API (currently not part of documentation):
mmf.Object.GetActionX (objid) -> ax
mmf.Object.GetActionY (objid) -> ay
mmf.Object.GetActionPoint (objid) -> ax, ay
Re: Getting Action Points in LUA?
looks like it is time for me to update my build. I have to go back and change a bunch of functions when I install this to avoid a ton of off by 1 errors from when you changed teh indexing on some of the functions. I'll tackle it in the morning.
Thanks for the addition though.. should come in really helpful. Relative position is just fine though... (probably better to be honest) It would be pretty cake to code a skeletal animation system using this too. (although rotations probably break nice and good with this)
Re: Getting Action Points in LUA?
Sorry, if you missed my last release update in the XLua beta topic, there was an important API change to the get/set value functions, to bring them into alignment with the rest of MMF. You may want to consider using the constants like mmf.ALT_A, mmf.ALT_B, etc, to be perfectly explicit about what you want to index.
Re: Getting Action Points in LUA?
Hey-
As far as I can tell, all of the functions:
mmf.Object.GetActionX (objid) -> ax
mmf.Object.GetActionY (objid) -> ay
mmf.Object.GetActionPoint (objid) -> ax, ay
seem to not be working. If I do something like this:
local xaction = mmf.Object.GetActionX(self.id)
It won't stop the program, but if I try to access the xaction, I get always get a nil value. (By the way, action point relative to sprite origin is much better in most cases, at least in my program.)
Re: Getting Action Points in LUA?
What i do for debugging is use the Popup message object to display and errors tha occur with xlua.
If its returning a nil value it could be that you are not exporting the object into LUA properly.
Re: Getting Action Points in LUA?
Send an example of it not working and I'll see what's up.
Re: Getting Action Points in LUA?
I will check when I get home and see if I can get it working and let you know also.
Re: Getting Action Points in LUA?
@Retriever2 - OK well I tested and found these results.
mmf.Object.GetActionX (objid) -> Returns the X spot perfectly
mmf.Object.GetActionY (objid) -> Returns the X spot and NOT Y spot
mmf.Object.GetActionPoint (objid) -> Returns both X and Y
So basically the GetActionY one by itself returns the same as the X, but when I do ActionPoint both X and Y work fine.
@Astrospoon - You must not be interfacing with MMF properly. If it returns a nil value its not linking in with MMF because it works for me.
Re: Getting Action Points in LUA?
Whoops you're right about the Y thing .. I'll post a fix later
Re: Getting Action Points in LUA?
Re: Getting Action Points in LUA?
I'm going to play around with it some again today. I am sure though that I am linked up with MMF correctly though. Why? Because over 2000 lines of LUA code already run the rest of my game correctly. In the line right above where I try and grab action points, I am grabbing other information from the same object that is working properly.
Re: Getting Action Points in LUA?
Hmm thats weird then. I tested it with one of my engines at it worked apart from the Y thing I mentioned above.