• We have updated our Community Code of Conduct. Please read through the new rules for the forum that are an integral part of Paradox Interactive’s User Agreement.

akarnokd

Recruit
23 Badges
Mar 16, 2018
5
0
  • Stellaris - Path to Destruction bundle
  • Stellaris: Ancient Relics
  • Stellaris: Megacorp
  • Shadowrun: Hong Kong
  • Shadowrun: Dragonfall
  • Shadowrun Returns
  • Stellaris: Distant Stars
  • Stellaris: Apocalypse
  • Stellaris: Humanoids Species Pack
  • Age of Wonders III
  • Stellaris: Synthetic Dawn
  • Surviving Mars
  • Stellaris: Leviathans Story Pack
  • Stellaris: Digital Anniversary Edition
  • Tyranny: Archon Edition
  • Stellaris: Galaxy Edition
  • Stellaris: Galaxy Edition
  • Stellaris
  • Pillars of Eternity
  • Crusader Kings II
  • Ancient Space
  • Magicka
  • Cities in Motion
I've created mods where the RC Explorers and RC Transports are automatically performing some tasks when they are idle (such as researching anomaly and collecting surface deposits). The scripting works great, but I'd like to add a button to their info panel that can toggle this automatic behavior on each individual rover.

I've downloaded some decoded LUA files containing the internal scripting as well as a building mods which adds a button to buildings (Workplace filter mod). Unfortunately, I wasn't able to add upgrades or new sections to a rover info panel:

Code:
function OnMsg.ClassesBuilt()
    PlaceObj("XTemplate", {
        group = "Infopanel Sections",
        id = "autoRover",
        PlaceObj("XTemplateTemplate", {
            '__context_of_kind', "RCTransport",
            "__template", "InfopanelSection",
            "Title", T{"Autonomous operation"},
            "RolloverText", T{"Autonomous operation"},
            "RolloverTitle", T{"Autonomous operation"},
            "RolloverHint",  T{"<left_click> Toggle filter"},
        })
    })
end

The code executes without any problems, the rovers do their autonomous things, but their info panel remains unchanged, no new "Autonomous operation" section is showing.

So far I've checked 600+ mods on Steam and none of them seems to try to mod rovers and their associated info panels.

Is such UI modding even possible with the rovers/drones?
 
With the help from the modding discord, I managed to hack in a new section:

XTemplates has an ipRover element with a single content. In there are the various rover panels and I had to insert a new XTemplateTemplate into it. Since I wanted some clickability, I've searched for active info panels and found the way to add a click handler:
Code:
   table.insert(XTemplates.ipRover[1],
        PlaceObj("XTemplateTemplate", {
            "__context_of_kind", "ExplorerRover",
            "__template", "InfopanelActiveSection",
            "Icon", "UI/Icons/Upgrades/factory_ai_02.tga", --"UI/Icons/Sections/sensor.tga",
            "Title", T{"Auto Explore"},
            "RolloverText", T{"Enable/Disable automatic exploration by this rover.<newline><newline>(AutoExplore mod)"},
            "RolloverTitle", T{"Auto Explore"},
            "RolloverHint",  T{"<left_click> Toggle setting"},
            "OnContextUpdate",
                function(self, context)
                    if context.auto_explore then
                        self:SetTitle(T{"Auto Explore (ON)"})
                        self:SetIcon("UI/Icons/Upgrades/factory_ai_02.tga")
                    else
                        self:SetTitle(T{"Auto Explore (OFF)"})
                        self:SetIcon("UI/Icons/Upgrades/factory_ai_01.tga")
                    end
                end,
        }, {
            PlaceObj("XTemplateFunc", {
                "name", "OnActivate(self, context)",
                "parent", function(parent, context)
                        return parent.parent
                    end,
                "func", function(self, context)
                        context.auto_explore = not context.auto_explore
                        ObjModified(context)
                    end
            })
        })
    )