Making trees stronger the farther they are from the spawn point

Place to get help with not working mods / modding interface.
Post Reply
Eylrid
Burner Inserter
Burner Inserter
Posts: 17
Joined: Sat Jul 02, 2016 4:36 pm
Contact:

Making trees stronger the farther they are from the spawn point

Post by Eylrid »

I'm trying to make a mod that makes trees stronger the further they are from the spawn point. Ideally it would change `max_health`, but that's not available on the fly. The next approach I thought of is to set `max_health` to a high amount and scale `health` with distance. I don't want the trees to heal, so I tried to use this code in data-updates.lua:

Code: Select all

for _, tree in pairs(data.raw.tree) do
    --make trees stonger
    tree.max_health = 1000000
    tree.healing_per_tick = 0
end
But it didn't seem to have any effect. The trees still heal. I tried setting `healing_per_tick` to other values to see what would happen. Nothing I set it to had any effect on the healing speed.

Is there something I'm doing wrong?

Is there a better way to do what I want to do?

User avatar
Ranakastrasz
Smart Inserter
Smart Inserter
Posts: 2124
Joined: Thu Jun 12, 2014 3:05 am
Contact:

Re: Making trees stronger the farther they are from the spawn point

Post by Ranakastrasz »

I can't give much more than sanity checks. That looks like it should work.

Mod is enabled.
Data is actually running. The include file thing.
Correct entity table.
Correct field names.

Past that, find a similar mod (adjusts all entities of a type) and copy from that before making changes.
My Mods:
Modular Armor Revamp - V16
Large Chests - V16
Agent Orange - V16
Flare - V16
Easy Refineries - V16

Eylrid
Burner Inserter
Burner Inserter
Posts: 17
Joined: Sat Jul 02, 2016 4:36 pm
Contact:

Re: Making trees stronger the farther they are from the spawn point

Post by Eylrid »

It successfully changes the max_health so the file is loading and the code is running, but it doesn't change the heal rate.

User avatar
darkfrei
Smart Inserter
Smart Inserter
Posts: 2903
Joined: Thu Nov 20, 2014 11:11 pm
Contact:

Re: Making trees stronger the farther they are from the spawn point

Post by darkfrei »

Eylrid wrote:
Mon Oct 28, 2019 6:42 am
It successfully changes the max_health so the file is loading and the code is running, but it doesn't change the heal rate.
Use the info-mod viewtopic.php?f=135&t=45107
You an check what your mod has changed.

mrvn
Smart Inserter
Smart Inserter
Posts: 5704
Joined: Mon Sep 05, 2016 9:10 am
Contact:

Re: Making trees stronger the farther they are from the spawn point

Post by mrvn »

Wouldn't setting the health to a fraction of max also make the health bar appear below every single tree on the map? I would be rather annoyed by that.

Post Reply

Return to “Modding help”