View unanswered posts | View active topics It is currently Fri Dec 27, 2024 7:45 am



Reply to topic  [ 5 posts ] 
 Calling functions of a mission via Lua 
Author Message
User avatar

Joined: Sat Jun 19, 2010 5:02 pm
Posts: 331
Location: Mekkan
Reply with quote
Post 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?


Fri Jul 23, 2010 6:05 pm
Profile
User avatar

Joined: Tue Nov 06, 2007 6:58 am
Posts: 2054
Reply with quote
Post Re: Calling functions of a mission via Lua
Err. GetActivity is a function.
Add some parens.
ActivityMan:GetActivity():[function]();

That should work.


Fri Jul 23, 2010 6:49 pm
Profile
User avatar

Joined: Sat Jun 19, 2010 5:02 pm
Posts: 331
Location: Mekkan
Reply with quote
Post 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]();


Fri Jul 23, 2010 7:26 pm
Profile
DRL Developer
DRL Developer
User avatar

Joined: Wed Dec 13, 2006 5:27 am
Posts: 3138
Location: A little south and a lot west of Moscow
Reply with quote
Post 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 :P


Fri Jul 23, 2010 9:37 pm
Profile WWW
User avatar

Joined: Sat Jun 19, 2010 5:02 pm
Posts: 331
Location: Mekkan
Reply with quote
Post 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 :P

Thanks!


Sat Jul 24, 2010 3:46 am
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 5 posts ] 

Who is online

Users browsing this forum: No registered users


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by STSoftware for PTF.
[ Time : 0.062s | 13 Queries | GZIP : Off ]