### Re: Resources.cfg

Posted:

**Mon Aug 28, 2017 9:08 am**Ok I write it a bit more clear, as you would implement such a function in escript:
GetUnits and DepleteUnits are just simple functions per coordinate you store the cfg entry available_units and subtract from it plus regenerate them over time.

So b can be interpreted as the cost and n is the maximum amount of such a "cost-block".

In the simplest example you want something like maximum 5 units with a cost of 1 each would need 1,5 as param. It results/depletes 0-5

Or something like get maximum 3 units with a cost of 10 each means as params 10,3. This means possible results/depletions are 0,10,20,30

Code: Select all

```
Function HarvestRessource(resource, x, y, b, n, realm)
Var avail_units := GetUnits(resource, x, y, realm);
Var temp := avail_units / b;
If (temp > n)
temp := n;
Endif
DepleteUnits(resource, x, y, realm, temp*b);
Return temp * b;
Endfunction
```

So b can be interpreted as the cost and n is the maximum amount of such a "cost-block".

In the simplest example you want something like maximum 5 units with a cost of 1 each would need 1,5 as param. It results/depletes 0-5

Or something like get maximum 3 units with a cost of 10 each means as params 10,3. This means possible results/depletions are 0,10,20,30