
Originally Posted by
hip63
Is there anyway this can be done for episode content? I'm trying to help ToonTotalWar put together The American Revolution Mod in a modolder format, but some the mod is based on episodic startpos files. Is it possible to something similar to this for so episodic stratpos files do not have to be overwritten? I'm working with both Episode 3 and Episode 4 startpos files. Any help would be greatly appreciated.
hip63

In principle, yes, but you'll need to work it through yourself. It's not going to be quite an easy fix. The easiest (somewhat messy, but meh) method is to insert code into the StartCampaign function to alter the Key of the selected campaign, for example by prepending a prefix, and changing the folder names accordingly. You will also have to compile the file with luac 5.1 afterwards
Code:
local utils = require("Utilities")
local options_manager = utils.Require("OptionsManager")
local this = (UIComponent(Address))
local prefs_manager = nil
local campaign_details = {}
local selected_campaign, current_prefs = nil, nil
InitDifficultySlider = function(l_1_0, l_1_1)
l_1_0:SetProperty("maxValue", 3)
l_1_0:LuaCall("Reset")
l_1_0:LuaCall("ValueSet", l_1_1)
l_1_0:SetProperty("Notify", Address)
UIComponent(l_1_0:Find("handle")):SetTooltipText(DifficultyLevelString(l_1_1), true)
end
DifficultyLevelString = function(l_2_0)
l_2_0 = utils.Clamp(l_2_0, 0, 3)
return FrontEnd.LocalisationString("difficulty_level_" .. tostring(l_2_0 + 1))
end
OnEnter = function()
local first_valid = nil
campaign_details = FrontEnd.EnumerateCampaigns(true)
for i,v in ipairs(campaign_details) do
v.Component = UIComponent(this:Find("chapter_" .. i, false))
if v == nil or v.Unlocked == false then
v.Component:SetState("inactive")
elseif first_valid == nil then
first_valid = i
end
end
if first_valid ~= nil then
SelectCampaign(first_valid)
end
prefs_manager = options_manager.CreateManager(FrontEnd)
options_manager.InitialisePrefsSetter(this, "game", InitialisePrefs)
InitDifficultySlider(UIComponent(this:Find("cmp_diff_slider")), current_prefs.campaign_difficulty)
InitDifficultySlider(UIComponent(this:Find("btl_diff_slider")), current_prefs.battle_difficulty)
UIComponent(this:Find("dy_faction_difficulty")):SetVisible(false)
end
InitialisePrefs = function(l_4_0)
current_prefs = l_4_0
end
Notify = function(l_5_0, l_5_1)
local cmp_diff_slider = this:Find("cmp_diff_slider")
local btl_diff_slider = this:Find("btl_diff_slider")
if l_5_0 == cmp_diff_slider or l_5_0 == this:Find("btl_diff_slider") then
FrontEnd.TriggerSliderUpdateEvent(UIComponent(l_5_0):Id())
UIComponent(UIComponent(l_5_0):Find("handle")):SetTooltipText(DifficultyLevelString(l_5_1), true)
if l_5_0 == cmp_diff_slider then
current_prefs.campaign_difficulty = l_5_1
elseif l_5_0 == btl_diff_slider then
current_prefs.battle_difficulty = l_5_1
end
prefs_manager:SetGameOptions(current_prefs)
end
end
SelectCampaign = function(l_6_0)
if selected_campaign ~= nil then
campaign_details[selected_campaign].Component:SetState("normal")
end
selected_campaign = l_6_0
campaign_details[selected_campaign].Component:SetState("selected")
local tv = UIComponent(this:Find("Textview"))
tv:LuaCall("SetText", campaign_details[l_6_0].Description)
local title = UIComponent(this:Find("dy_chapter"))
title:SetStateText(campaign_details[l_6_0].Name)
end
StartCampaign = function()
FrontEnd.StartCampaign(campaign_details[selected_campaign].Key)
end