Looking For help with mod

I am trying to create a noob freindly eco mod however my understanding of script is very limited.

I am trying to reduce the mass cost of units based on their tech level but i dont now how to right that in script, could somebody show me how this is done, bellow is a simple mod i copied from another.Untitled.jpg

I need that effect applied to tech levels at different scales, thankyou.

@Zukko

local OldModBlueprintsFunction = ModBlueprints
function ModBlueprints(all_blueprints)
    OldModBlueprintsFunction(all_blueprints)
    -- loop over all blueprints
    for id,bp in all_blueprints.Unit do
        -- get the tech level / mass scale for this unit
        local CostMassScale = 0
        if bp.CategoriesHash.TECH1 then
            CostMassScale = 0.4
        elseif bp.CategoriesHash.TECH2 then
            CostMassScale = 0.6
        elseif bp.CategoriesHash.TECH3 then
            CostMassScale = 0.8
        elseif bp.CategoriesHash.EXPERIMENTAL then
            CostMassScale = 1.0
        end
        -- check if we have an Economy table with BuildCostMass
        if bp.Economy.BuildCostMass then
            LOG("Changing BuildCostMass for unit ["..id.."] from "..(bp.Economy.BuildCostMass).." to "..(bp.Economy.BuildCostMass * CostMassScale).."")
            bp.Economy.BuildCostMass = bp.Economy.BuildCostMass * CostMassScale
        end
        -- check if we have an Enhancements table
        if bp.Enhancements then
            -- loop over all table entries and check for mass cost
            for index, enhancement in bp.Enhancements do
                -- doe the enhancment has BuildCostMass ?
                if enhancement.BuildCostMass then 
                    LOG("Changing BuildCostMass for enhancement on unit ["..id.."] from "..(enhancement.BuildCostMass).." to "..(bp.Enhancements[index].BuildCostMass * CostMassScale).."")
                    bp.Enhancements[index].BuildCostMass = bp.Enhancements[index].BuildCostMass * CostMassScale
                end
            end
        end
    end
end

@Uveso

Thank you very much, that works perfectly!

There is one more thing i need help on to finish the mod if you have time?

The aim of the mod is to make things easier for new players by reducing apm aswell as reduce the advantages that a higher rated player will have against newer players, one of these ideas is to remove reclaim.

I thought about removing the ability for engineers and commanders but this would prove highly impractal for placing buildings ontop of trees etc, so the only way i can imagine achieving this would be to remove the economy gained from reclaiming.

Do you now how or even if this ispossible, thanks again.

Create a new text file and name it 'Prop.lua'

Copy the file to your mod into:
\Mods\YOURMOD\hook\lua\sim\

now edit the file
(\Mods\YOURMOD\hook\lua\sim\Prop.lua)

copy this into the prop.lua file:

-- Saving the Prop class, so we can hook it
local oldProp=Prop
-- create a new Prop class based on the original oldProp class
Prop = Class(oldProp) {
    -- overwrite the original GetReclaimCosts function with our own:
    GetReclaimCosts = function(self, reclaimer)
        -- Set reclaim parameter
        local ReclaimTime = 1 -- Don't set it to 0 or we will devide by 0 later
        local MassReclaim = 0
        local EnergyReclaim = 0
        -- return the new raclaim values
        return ReclaimTime, EnergyReclaim, MassReclaim
    end,
}

This will set the reclaim time to 1 tick and reclaim cost/gain to 0

@Uveso

Thats brilliant thankyou, your help is most appreciated

You are welcome!

@uveso

After a few days of trying to balance this mod i have thought of a much better idea for a noob friendly hands off ecocomy mod
than before.

Is it possible to make all mass extractors increase their production once built increase by 1 mass ps every minute with a max cap of 30 mass production per second ?

So that after a 28 minute game a tech 1 extractor would reach 30 mass per second

All of that is possible - yes. It is best to join the #modding-general channel on the official discord and ask for help there. That way more people can assist you than just Uveso 🙂

A work of art is never finished, merely abandoned

@Zukko
like Jip already stated, almost everything is possible. Just a matter of time to code it.

So yes you can increase the mass output like you descibed.

Its also possible to lower or increase the buildcost of all stuff and also change the build time.
Like the cheat option for the AI you could make a handicap function for one or all players.

But this will need deep knowledge about the game function to mod this.
So join us in the discord that jip already posted.

@Jip
As always, thank you for you help 😄