munitionLauncherUtils
(For high level concepts about how to use Lua to write scripted tasks, please see VR-Forces User's Guide.)
This package contains some functions that support munition-launching scripts such as Delayed_homing and Launch_ASW_Missile. In these scripts, the launcher gets the desired launcher system in the init() function and calls setAttribute("launch-munition") to cause the system to create a munition. In the tick function, the launcher gets the munition name from the system, confirms that it is a valid entity, and starts a task on it. To use, add this to the beginning of your script:
require "munitionLauncherUtils"
The functions in this module are global, so can be used without prefixing them with munitionLauncherUtils.
Function List
| launcherInit (launcherName, target) | This function gets the indicated system and calls setAttribute on it to launch a munition. |
| launcherTaskMunition (launcherSystem, taskName, initTime, timeout, munitionPrevFound) | This function tasks the munition launched by the given system with the given task. |
Functions
- launcherInit (launcherName, target)
-
This function gets the indicated system and calls setAttribute on it to launch a munition. If it encounters an error, it will end the task.
Parameters:
-
launcherName: The name (string) of the launcher system. -
target: The entity being targeted.
Return value:
- the launcher system object.
-
- launcherTaskMunition (launcherSystem, taskName, initTime, timeout, munitionPrevFound)
-
This function tasks the munition launched by the given system with the given task. It confirms first that it has a valid entity name from the system; if it does not get one within the timeout, it aborts the task. If it is successful in tasking the munition, it ends the task (status true). When it tasks the munition, it provides a parameter parentLauncher that is the name of this entity (i.e., the launcher's platform); therefore the task can be a polymorphic task that uses the parentLauncher as a key to determine whether the launcher or munition is running it.
Parameters:
-
launcherSystem: A system object; the launcher that just launched a munition. -
taskName: The name (string) of the task to run on the munition. -
initTime: The exercise time (seconds) when the launcher was told to create the munition. -
timeout: The amount of time (seconds) to keep trying to get the name of the munition before giving up and aborting the task. -
munitionPrevFound:
-
