mirror of
https://github.com/dcs-retribution/dcs-retribution.git
synced 2025-11-10 15:41:24 +00:00
Introduced LUA scripts plugins
In order to be able to customize the scripts that can be injected in the mission, a __plugin.lst file is read and the scripts mentionned in this file are injected (through DoScriptFile and not DoScript). A mechanism checks if a standard script (Mist, JTACAutolase) has already been loaded, to avoid loading them twice.
This commit is contained in:
parent
83f221c5e3
commit
84da44a27b
@ -234,13 +234,41 @@ class Operation:
|
|||||||
if self.game.settings.perf_smoke_gen:
|
if self.game.settings.perf_smoke_gen:
|
||||||
self.visualgen.generate()
|
self.visualgen.generate()
|
||||||
|
|
||||||
# Inject Lua Scripts
|
# Inject Plugins Lua Scripts
|
||||||
load_mist = TriggerStart(comment="Load Mist Lua Framework")
|
listOfPluginsScripts = []
|
||||||
with open("./resources/scripts/mist_4_3_74.lua") as f:
|
try:
|
||||||
load_mist.add_action(DoScript(String(f.read())))
|
with open("./resources/scripts/plugins/__plugins.lst", "r") as a_file:
|
||||||
self.current_mission.triggerrules.triggers.append(load_mist)
|
for line in a_file:
|
||||||
|
name = line.strip()
|
||||||
|
if not name.startswith( '#' ):
|
||||||
|
trigger = TriggerStart(comment="Load " + name)
|
||||||
|
listOfPluginsScripts.append(name)
|
||||||
|
fileref = self.current_mission.map_resource.add_resource_file("./resources/scripts/plugins/" + name)
|
||||||
|
trigger.add_action(DoScriptFile(fileref))
|
||||||
|
self.current_mission.triggerrules.triggers.append(trigger)
|
||||||
|
except Exception as e:
|
||||||
|
print(e)
|
||||||
|
|
||||||
# Load Ciribob's JTACAutoLase script
|
# Inject Mist Script if not done already in the plugins
|
||||||
|
if not "mist.lua" in listOfPluginsScripts and not "mist_4_3_74.lua" in listOfPluginsScripts: # don't load mist twice
|
||||||
|
trigger = TriggerStart(comment="Load Mist Lua Framework")
|
||||||
|
fileref = self.current_mission.map_resource.add_resource_file("./resources/scripts/mist_4_3_74.lua")
|
||||||
|
trigger.add_action(DoScriptFile(fileref))
|
||||||
|
self.current_mission.triggerrules.triggers.append(trigger)
|
||||||
|
|
||||||
|
# Inject Liberation script
|
||||||
|
load_dcs_libe = TriggerStart(comment="Load DCS Liberation Script")
|
||||||
|
with open("./resources/scripts/dcs_liberation.lua") as f:
|
||||||
|
script = f.read()
|
||||||
|
json_location = "[["+os.path.abspath("resources\\scripts\\json.lua")+"]]"
|
||||||
|
state_location = "[[" + os.path.abspath("state.json") + "]]"
|
||||||
|
script = script.replace("{{json_file_abs_location}}", json_location)
|
||||||
|
script = script.replace("{{debriefing_file_location}}", state_location)
|
||||||
|
load_dcs_libe.add_action(DoScript(String(script)))
|
||||||
|
self.current_mission.triggerrules.triggers.append(load_dcs_libe)
|
||||||
|
|
||||||
|
# Load Ciribob's JTACAutoLase script if not done already in the plugins
|
||||||
|
if not "JTACAutoLase.lua" in listOfPluginsScripts: # don't load JTACAutoLase twice
|
||||||
load_autolase = TriggerStart(comment="Load JTAC script")
|
load_autolase = TriggerStart(comment="Load JTAC script")
|
||||||
with open("./resources/scripts/JTACAutoLase.lua") as f:
|
with open("./resources/scripts/JTACAutoLase.lua") as f:
|
||||||
|
|
||||||
@ -258,16 +286,6 @@ class Operation:
|
|||||||
load_autolase.add_action(DoScript(String(script)))
|
load_autolase.add_action(DoScript(String(script)))
|
||||||
self.current_mission.triggerrules.triggers.append(load_autolase)
|
self.current_mission.triggerrules.triggers.append(load_autolase)
|
||||||
|
|
||||||
load_dcs_libe = TriggerStart(comment="Load DCS Liberation Script")
|
|
||||||
with open("./resources/scripts/dcs_liberation.lua") as f:
|
|
||||||
script = f.read()
|
|
||||||
json_location = "[["+os.path.abspath("resources\\scripts\\json.lua")+"]]"
|
|
||||||
state_location = "[[" + os.path.abspath("state.json") + "]]"
|
|
||||||
script = script.replace("{{json_file_abs_location}}", json_location)
|
|
||||||
script = script.replace("{{debriefing_file_location}}", state_location)
|
|
||||||
load_dcs_libe.add_action(DoScript(String(script)))
|
|
||||||
self.current_mission.triggerrules.triggers.append(load_dcs_libe)
|
|
||||||
|
|
||||||
self.assign_channels_to_flights()
|
self.assign_channels_to_flights()
|
||||||
|
|
||||||
kneeboard_generator = KneeboardGenerator(self.current_mission)
|
kneeboard_generator = KneeboardGenerator(self.current_mission)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user