Data Realms Fan Forums http://45.55.195.193/ |
|
Calling functions of a mission via Lua http://45.55.195.193/viewtopic.php?f=73&t=19317 |
Page 1 of 1 |
Author: | Awesomeness [ Fri Jul 23, 2010 6:05 pm ] |
Post subject: | Calling functions of a mission via Lua |
I have a scripted object that I need to "communicate" with the current mission. I need the object to call a function of the mission it's in. I tried ActivityMan:GetActivity:[function](); but it doesn't work. Is there a simple way to do this? |
Author: | mail2345 [ Fri Jul 23, 2010 6:49 pm ] |
Post subject: | Re: Calling functions of a mission via Lua |
Err. GetActivity is a function. Add some parens. ActivityMan:GetActivity():[function](); That should work. |
Author: | Awesomeness [ Fri Jul 23, 2010 7:26 pm ] |
Post subject: | Re: Calling functions of a mission via Lua |
mail2345 wrote: Err. GetActivity is a function. Add some parens. ActivityMan:GetActivity():[function](); That should work. Whoops, I did that, I just typed it in wrong in the OP. Two other things that might affect this: -I'm not trying to do functions like SetTeamFunds, I'm doing functions defined in the lua for the mission. Do I need to do something else to get the class for my mission? (E.G. Is the class returned by GetActivity() different than my mission's Lua class?) -I am also doing this instead of directly doing GetActivity() each time: (Though I don't think it would matter...) Code: self.Activity = ActivityMan.GetActivity; self.Activity:[function](); |
Author: | TheLastBanana [ Fri Jul 23, 2010 9:37 pm ] |
Post subject: | Re: Calling functions of a mission via Lua |
You want to call the function by the activity's Lua name. So, for instance, if this is your Update function: Code: function AMission:UpdateActivity() ... end Call it in the console like so: Code: AMission:UpdateActivity() It's such a simple thing and it's sitting there right in front of your nose, but it took me a good half hour of trial and error to figure his one out when I was trying to do it ![]() |
Author: | Awesomeness [ Sat Jul 24, 2010 3:46 am ] |
Post subject: | Re: Calling functions of a mission via Lua |
TheLastBanana wrote: You want to call the function by the activity's Lua name. So, for instance, if this is your Update function: Code: function AMission:UpdateActivity() ... end Call it in the console like so: Code: AMission:UpdateActivity() It's such a simple thing and it's sitting there right in front of your nose, but it took me a good half hour of trial and error to figure his one out when I was trying to do it ![]() Thanks! |
Page 1 of 1 | All times are UTC [ DST ] |
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group http://www.phpbb.com/ |