So I am currently working on a mod, and I need to know if there is a way to "pull" what units are selected from PA. For instance if i am in-game and i have 3 adv vehicle fabbers and 20 bot fabbers is there any way for me to pull that those units are selected from PA to use in a UI mod? Again I would need to know what units are selected and how many of each unit is selected.
Take a look at SelectionViewModel in live_game.js (line 370). You can get the current selection details from there.
God, hate my limited knowledge of js i am trying to learn as I go and I don't understand the code in live_game.js or in the build power mod, if it wouldn't be too much trouble could someone write me a code snippet to pass what units are selected to js?
I haven't tested it, but the link elitedanzel sent to his mod has what you want. From his GitHub, it seems you need to take over the function handler.selection. So something like this (in less convoluted JavaScript ) : Code: var oldselectionhandler = handler.selection; // Save the original handler.selection = function (payload) { oldselectionhandler(payload); // Apply the original first // Do your stuff with payload here! console.log(payload); }; You can use the Debugger to inspect the contents of payload to take what you want. You can also look at the function self.parseSelection on line 1410 in live_game.js to see how PA handles the payload. Hope that helps!
I will look into it when I get home but right now I have School so I won't be back until 3 pm est, I will let you guys know what I have figured out.