Page 1 of 1

[misc] LuaMex for all! Complete engine mex replacement!

Posted: 24 Jan 2017, 07:38
by Forboding Angel

This is a spinoff of luamex that was originally created for Complete Annihilation and then later expanded for use in Zero-K. We wanted a system that could be dropped into any Spring Game which would immediately replace hardcoded engine metal extraction points with lua controlled points. An added benefit of this method is that the gamedev can create lua mexmap configs that will override the hardcoded ones in the map. Therefore, you can make each map specifically cater to your needs.

Continue reading →

Re: LuaMex for all!

Posted: 24 Jan 2017, 07:42
by Forboding Angel
Huge Thanks to:

* CarRepairer for EasyMetal, the widget precursor to lua mexes
* Google Frog for expanding it to a gadget
* Sprung for abstracting lua-mex so that it can work with any spring game

Without Sprunk I would have gotten precisely nowhere in these efforts and he did all the work to make it function.

# How it functions


There are 4 main components to luamex itself:

* gadgets/mex_placement.lua
* gadgets/mex_spot_finder.lua
* widgets/api_mexspot_fetcher.lua
* widgets/cmd_mex_placement.lua

For upgrading mexes, there are two subcomponents. They are:
* gadgets/unit_mex_upgrader.lua
* widgets/cmd_mex_upgrade_helper.lua


Luamex first uses the finder to find all of the mex spots on a map, them puts them in a table that is then made available to other gadgets and to widgets via the fetcher. From this, mex placement can then place mexes directly on the mex spots. Additionally, it will display the amount of metal that the mex spot will yield on the map itself. Mexspots are drawn directly on the map and on the minimap as well. Neutral metal spots will be displayed in grey, and captured ones will be displayed in the owner team's teamcolor.

For each builder a customparam can be added to that builder. This customparam is:
area_mex_def = "<UnitNameOfYourMex>",

Every builder with this customparam will receive a button on their orders menu that says "Mex". Clicking on this button and drawing a circle will cause mexes to be queued up everywhere within that circle. This customparam controls which mex is automatically queued for each builder.

## Upgrading mexes


For your convenience, the old mex upgrader script has been revitalized and altered to work for pretty much any spring game. It uses the extract's metal amount to compare unitdefs, and if a builder can build a mex with a larger extraction rate, it is given an upgrade mex button. This works exactly like the mex button previously mentioned. The builder will travel to the mex spot, reclaim the previous mex and build the appropriate upgraded one. By default, mexes with weapons, stealth, cloaked, etc will attempt to build into advanced mexes with those attributes. For this reason, in Balanced Annihilation, a basic exploiter mex with the llt will be upgraded into the moho exploiter with the large cannon.

This behavior can be toggled on lines 13 and 14 in gadgets/unit_mex_upgrader.lua (ignoreWeapons/ignoreStealth = true/false). Additionally, behavior can be fine tuned in function processMexData().

# Custom Mexmap Configs

Custom mexmap configs are to be placed here:
* LuaRules/Configs/MetalSpots/<mapname>.lua

If you are a mapper and wish to include a lua mexmap config (a far better solution than hardcoding the metalmap), you cna place your config here:
* mapconfig/map_metal_layout.lua

# Report bugs!

Please be sure to report any bugs found on the project bug tracker, located here: ... Mex/issues


Download it here:

Re: [misc] LuaMex for all!

Posted: 24 Jan 2017, 13:13
by sprunk
Also credit to CarRepairer whose EasyMetal was the original.

Re: [misc] LuaMex for all!

Posted: 25 Jan 2017, 12:43
by Floris
Would be really appreciated if a t2 builder would upgrade t1 mexspots aswell

Re: [misc] LuaMex for all!

Posted: 25 Jan 2017, 16:24
by Forboding Angel
I don't understand. Did you read the upgrading mexes section?

Re: [misc] LuaMex for all!

Posted: 25 Jan 2017, 16:49
by Floris
when i gave an area mex command havin t2 con selected. it didnt upgrade any t1 mexes within the area

Re: [misc] LuaMex for all!

Posted: 25 Jan 2017, 16:53
by Forboding Angel
Use mex command on unclaimed mexes, upgrade command/upgrader on toggle on claimed mexes. It would have been nice to have it all inclusive, but sadly not really feasible.

Re: [misc] LuaMex for all!

Posted: 26 Jan 2017, 20:30
by Forboding Angel
I lied. As of yesterday it became a reality, once again thanks to sprunk.

I would like to point out that Lua-Mex now completely bypasses engine mexes. This is a AMAZING accomplishment. Don't misunderstand, you can still use maps that are made with hardcoded engine mex spots, but the actual income and placement and all that is now handled completely by lua. No more weird extractsmetal 0.001 stuff to worry about. it is now handled by a very nice and neat customparam multiplier.

Refer to updated readme for more details.

If you want to see it in action, latest BA alpha has it implemented and I am implementing it as a modoption in Evoluton RTS as I type.

Edit: Just added some customization options in the placement widget so that you won't be limited in how you display resource nodes.

Edit2: Broke the options table out into a config so that if you use custom settings you won't over your options set overridden every time you update. I had to make this a reality because evo uses some fairly complicated settings due to several different ways to do income in the game(modoptions).

Re: [misc] LuaMex for all!

Posted: 27 Jan 2017, 06:59
by Forboding Angel
Big thanks to Floris... Circles are now sexy AND they are animated!


Re: [misc] LuaMex for all! Complete engine mex replacement!

Posted: 28 Jan 2017, 22:06
by Karl
How does it work on maps where the metal spot is much larger and have non regular/non circular shapes or in Metal Maps such as Core Prime?

Re: [misc] LuaMex for all! Complete engine mex replacement!

Posted: 29 Jan 2017, 01:01
by Forboding Angel
In metal maps, it just functions normally, no spots.

On cloud metal maps it does maths(TM) and creates spots for you.

Remember, you can create mexmaps configs very quickly and easily if you don't like the metal layout of a certain map.