mirror of
https://github.com/FlightControl-Master/MOOSE_MISSIONS.git
synced 2025-08-15 10:37:46 +00:00
Update Python script
- Script will now search for all lua files that start with "moose" (case insensitive) and replace them with the most current Moose_.lua - Script will now extract all lua files that do NOT start with "moose" (case insensitive) and place them next to the miz file
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
"""
|
||||
This script finds all miz files and updates the contained Moose.lua from a given one.
|
||||
|
||||
It also extracts the contained mission script and places it next to the miz file.
|
||||
Here we assume that the stem of the file name is the same as the directory name, e.g.
|
||||
"Auftrag - 10 - Arty.lua" if the miz file name is "Auftrag - 10 - Arty.miz"
|
||||
All files that end with lua and do NOT start with Moose are extracted.
|
||||
|
||||
This script is supposed to be run from, e.g., github actions when a new demo mission is
|
||||
uploaded.
|
||||
@@ -15,12 +15,26 @@ from shutil import rmtree, copy
|
||||
import argparse
|
||||
import filecmp
|
||||
|
||||
def findMoose(path: Path):
|
||||
# Loop over all lua files (recursively)
|
||||
for f in path.rglob("*.lua"):
|
||||
if f.name.lower().startswith("moose"):
|
||||
print(f"Found Moose file as: {f}")
|
||||
return f
|
||||
|
||||
def copyScripts(path: Path, topath):
|
||||
# Loop over all lua files (recursively)
|
||||
for f in path.rglob("*.lua"):
|
||||
if not f.name.lower().startswith("moose"):
|
||||
print(f"Found script: {f}")
|
||||
copy(f, topath)
|
||||
|
||||
def update(f: Path, MooseLua: Path, Temp: Path):
|
||||
"""
|
||||
Update the Moose.lua file in given file.
|
||||
"""
|
||||
# Print file name.
|
||||
print(f"Updating file: {f}")
|
||||
print(f"Checking file: {f}")
|
||||
|
||||
# Extract all the contents of zip file in different directory
|
||||
with ZipFile(f, mode='r') as miz:
|
||||
@@ -34,23 +48,36 @@ def update(f: Path, MooseLua: Path, Temp: Path):
|
||||
print(f"WARNING: {ScriptDir.name} does not exit!")
|
||||
return
|
||||
|
||||
# Find old Moose file in Scrit directory.
|
||||
MooseOld=findMoose(ScriptDir)
|
||||
if not MooseOld.is_file():
|
||||
print("WARNING: Could not find any file that starts with Moose!")
|
||||
return
|
||||
|
||||
|
||||
# Copy all script files (all files that do NOT start with moose and end with lua)
|
||||
copyScripts(ScriptDir, f.parent)
|
||||
|
||||
# Script file.
|
||||
ScriptFile=ScriptDir/Path(f.stem + ".lua")
|
||||
#ScriptFile=ScriptDir/Path(f.stem + ".lua")
|
||||
|
||||
#Copy script file to directory.
|
||||
if ScriptFile.is_file():
|
||||
print(f"Copying script file {ScriptFile} to {f.parent}")
|
||||
copy(ScriptFile, f.parent)
|
||||
else:
|
||||
print(f"Warning: expected script file {ScriptFile} does NOT exist in miz file!")
|
||||
#if ScriptFile.is_file():
|
||||
# print(f"Copying script file {ScriptFile} to {f.parent}")
|
||||
# copy(ScriptFile, f.parent)
|
||||
#else:
|
||||
# print(f"Warning: expected script file {ScriptFile} does NOT exist in miz file!")
|
||||
|
||||
# Check if Moose.lua file is already.
|
||||
if filecmp.cmp(MooseLua, ScriptDir/"Moose.lua"):
|
||||
print(f"INFO: Moose.lua file is up-to-date ==> Nothing to do!")
|
||||
if filecmp.cmp(MooseLua, MooseOld):
|
||||
print(f"INFO: {MooseOld.name} file is up-to-date ==> Nothing to do!")
|
||||
else:
|
||||
|
||||
# Info.
|
||||
print(f"INFO: Updating {MooseOld.name} with current version")
|
||||
|
||||
# Copy Moose.lua to temp dir.
|
||||
copy(MooseLua, ScriptDir/"Moose.lua")
|
||||
copy(MooseLua, MooseOld)
|
||||
|
||||
# Create new miz file
|
||||
with ZipFile(f, mode='w') as archive:
|
||||
|
||||
@@ -1,51 +0,0 @@
|
||||
---
|
||||
-- Name: TAD-A2G-100 - TYPES - Detection Test
|
||||
-- Author: FlightControl
|
||||
-- Date Created: 15 Mar 2018
|
||||
--
|
||||
-- # Situation:
|
||||
--
|
||||
-- This mission demonstrates the dynamic task dispatching for Air to Ground operations.
|
||||
-- Reconnassance vehicles are placed at strategic locations, scanning for the enemy locations.
|
||||
-- The detection method used is the DETECTION_TYPES method, which groups detected targets into Unit Types that were detected.
|
||||
-- The AttackSet will engage upon the enemy, which is a Set of Groups seated by Players.
|
||||
-- A2G Tasks are being dispatched to the Players as enemy locations are being detected by the Recce.
|
||||
-- Observe that A2G Tasks are being dispatched to the player.
|
||||
|
||||
|
||||
-- Declare the Command Center
|
||||
local HQ = GROUP
|
||||
:FindByName( "HQ", "Bravo HQ" )
|
||||
|
||||
local CommandCenter = COMMANDCENTER
|
||||
:New( HQ, "Lima" ) -- Create the CommandCenter.
|
||||
|
||||
-- Declare the Mission for the Command Center.
|
||||
local Mission = MISSION
|
||||
:New( CommandCenter, "Overlord", "High", "Attack Detect Mission Briefing", coalition.side.RED ) -- Create the Mission.
|
||||
|
||||
-- Define the RecceSet that will detect the enemy.
|
||||
local RecceSet = SET_GROUP
|
||||
:New() -- Create the RecceSet, which is the set of groups detecting the enemy locations.
|
||||
:FilterPrefixes( "Recce" ) -- All Recce groups start with the name "Recce".
|
||||
:FilterCoalitions("red") -- only the red coalition.
|
||||
:FilterStart() -- Start the dynamic building of the set.
|
||||
|
||||
-- Setup the detection. We use DETECTION_AREAS to detect and group the enemies.
|
||||
local DetectionAreas = DETECTION_TYPES
|
||||
:New( RecceSet ) -- The RecceSet will detect the enemies, and group them into unit types that were detected.
|
||||
|
||||
-- Setup the AttackSet, which is a SET_GROUP.
|
||||
-- The SET_GROUP is a dynamic collection of GROUP objects.
|
||||
local AttackSet = SET_GROUP
|
||||
:New() -- Create the SET_GROUP object.
|
||||
:FilterCoalitions( "red" ) -- Only incorporate the RED coalitions.
|
||||
:FilterPrefixes( "Attack" ) -- Only incorporate groups that start with the name Attack.
|
||||
:FilterStart() -- Start the dynamic building of the set.
|
||||
|
||||
-- Now we have everything to setup the main A2G TaskDispatcher.
|
||||
TaskDispatcher = TASK_A2G_DISPATCHER
|
||||
:New( Mission, AttackSet, DetectionAreas ) -- We assign the TaskDispatcher under Mission. The AttackSet will engage the enemy and will recieve the dispatched Tasks. The DetectionAreas will report any detected enemies to the TaskDispatcher.
|
||||
|
||||
-- We use the MISSILETRAINER for demonstration purposes.
|
||||
MissileTrainer = MISSILETRAINER:New( 100, "Missiles will be destroyed for training when they reach your plane." )
|
||||
Reference in New Issue
Block a user