MMMApp Framework

Every MMM script has a class that MMM will interact with. This class is registered with MMM by calling MMM.register and can optionally provide definitions for several different functions.

MMMApp overview

Here are the functions that MMM will call on an MMMApp, what they do and when they will be called.

setup

setup is called once when the mission is first started. This is a good place to perform initial mission set up, such as allocating starting resources, setting up relations, finding key objects, defining paths, amongst other things.

update

update is called every time the update interval is reached (this can be set with Armada.setUpdateTime). This is where you can check to see if conditions have been met for objectives, or whatever your mission needs to do.

resume

When a save file is loaded this function is called in place of setup. You should resume the mission from the data contained in the save file. You can save data using the Save and Load interfaces.

cineractiveBegin

This function will be called some time after you tell MMM to begin a cineractive. In here you can set up the cineractive that is about to be played.

cineractiveUpdate

This function is called every update while a cineractive is active. In here you should check for the conditions that are required to end the cineractive and end it if necessary, and perform actions to continue the cineractive like focusing on objects.

cineractiveFinish

This function is called after you tell the cineractive to end. You should prepare the mission for reentry into the game mode. This function takes a boolean parameter that indicates if the cineractive was forcibly ended (by the player). If this is true you should make sure the mission is ready to go as if it the cineractive had finished naturally.

Creating your own MMMApp

You can create your own derived application quite simply, override any functions you wish to, and ignore any you don't need. Here's how you go about this.

	--This part creates the table we will use for the mission
--an initialises the metatable, allowing it to work properly
--with MMMApp
class 'TestMission'

function TestMission:__init( )

end

function TestMission:setup( )
    --Setup code would go here.
end

function TestMission:update( )
     --Update code would go here.
end

--This line registers the App with MMM. This makes it MMM call the app's functions.
MMM.register( TestMission( ) )

If you wanted to add cineractiveUpdate for example, you would simply do this :

	function TestMission:cineractiveUpdate( )
     --Do something in here.
end

There may be other functions added to MMMApp in the future, and to use them you simply have to add them to your app. Here is an empty framework that you can use as a base for new missions. It has every function that is currently supported already defined with explanations for how they should be used.

--This part creates the table we will use for the mission
--an initialises the metatable, allowing it to work properly
--with MMMApp
class 'TestMission'

function TestMission:__init( )
	--You can set up properties for the mission here, or you can do it in setup. 
end

--Called once when the mission is first started. Ideal place to set up the variables and structures
--needed for the mission.
function TestMission:setup( )
    
end

--Called when the mission is loaded from a save game. You should load any data that was saved in this
--function and prepare for the mission to carry on.
function TestMission:resume( )

end

--This is called some time after you tell MMM to start a cineractive - you can set up the cineractive that
--is going to be played and prepare the game world for cineractive mode.
function TestMission:cineractiveBegin( )

end

--This is called every update while a cineractive is running. You should check for conditions you require for
--the end of the cineractive and end it if needed. You can also change the running cineractive, to focus on another
--ship for example.
function TestMission:cineractiveUpdate( )

end

--The is called some time after you tell MMM to end the cineractive. This is where you prepare the game world for
--game mode again. Forced indicates if the cineractive was forcibly ended or not.
function TestMission:cineractiveFinish( forced )
	
end

--This is called every time MMM updates. This frequency can change based on the value specified to Armada.updateTime.
function TestMission:update( )
     
end

--This line registers the App with MMM. This makes it MMM call the app's functions.
MMM.register( TestMission( ) )