Data Realms Fan Forums
http://868000.nnhp.asia/

Pie menu handler unable to interact with my code
http://868000.nnhp.asia/viewtopic.php?f=73&t=31562
Page 1 of 1

Author:  TND [ Thu Aug 09, 2012 6:30 am ]
Post subject:  Pie menu handler unable to interact with my code

I have this pie menu event handler, which I am certain is being called: (me using Mode instead of AIMode is intentional, by the way)
Code:
function GoTo(actor)
   actor.Mode = Actor.AIMODE_GOTO;
   print("Pie goto");
end

But you know what's weird? Even though I've confirmed it's the same Actor, (same ID, everything) any custom variable (like, not something such as Weight) is nil from GoTo's point of view. So, for example, in the Create of the actor, I set self.Mode to Sentry, the constant for 1, but then when I look at it from GoTo, it's nil. The function acts like a little tempory black hole, where any change to actor is completely ignored by the rest of the code, and forgotten when the function finishes.

What can I do to fix this? This is weird ._.

Author:  Coops [ Thu Aug 09, 2012 6:58 am ]
Post subject:  Re: Pie menu handler unable to interact with my code

Have you tried getting the Controller of the actor first?

Does the console say anything?

Author:  TND [ Thu Aug 09, 2012 8:31 am ]
Post subject:  Re: Pie menu handler unable to interact with my code

Console says nothing, other than what I tell it to print of course. What would I do with a Controller?

Author:  Coops [ Thu Aug 09, 2012 8:49 am ]
Post subject:  Re: Pie menu handler unable to interact with my code

I was thinking of the wrong thing.

Have you tried this instead?

Code:
actor.Mode = 3


Im not sure why you want to use Mode instead of AIMode but you can change it to that for further debuging.

Author:  Abdul Alhazred [ Thu Aug 09, 2012 9:21 am ]
Post subject:  Re: Pie menu handler unable to interact with my code

The way CC expose the underlying C++ code to Lua makes it impossible to do what you want. Custom Lua variables are only readable from within the object they were created.

A common workaround is to use the sharpness of the actor/object or a global variable for communication between game objects.

Page 1 of 1 All times are UTC [ DST ]
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/