Jump to content

Odd behaviours with modded TUNING values


_zwb
  • DLC VERSION - IMPORTANT!: Vanilla - NO DLC, Reign of Giants, Shipwrecked, Hamlet Pending

I'm working on porting the farming update to DS, and in the file "prefabs/farm_plant_defs" there are some properties using DST only TUNING values, so I put them in another file and imported them in modmain.lua. However those values are not actually assigned, dumptable shows that any field with modded TUNING values are not actually set, but the TUNING values themselves are.

However, once I've put the modimport call of my tuning file before adding values to PrefabFiles table, those modded values got assigned and worked correctly. Is this intended to work this way?


Steps to Reproduce

1. Have all your modded tuning values in a separate lua file and import it after adding values to PrefabFiles table

2. Have another script file that returns a table, with some fields using the modded values and some don't.

3. In the prefab file, require the script file and notice how those modded values aren't actually assigned. Try doing an arithmetic operation and an error will show up.

4. Import tuning values file before adding values to PrefabFiles table, things work perfectly fine now.

--main/tuning.lua:
GLOBAL.TUNING.FARM_PLANT_DROUGHT_TOLERANCE = 0.1

--modmain.lua in step 1:
PrefabFiles = 
{
    "farm_plants", -- This file requires farm_plant_defs.lua
}
modimport("main/tuning.lua")
--modmain.lua in step 4:
modimport("main/tuning.lua")
PrefabFiles = 
{
    "farm_plants", -- This file requires farm_plant_defs.lua
}

 

  • Like 1



User Feedback


One odd thing about this is that in log.txt it shows the file "main/tuning.lua" is imported before registering prefabs for "prefabs/farm_plants.lua", shouldn't this make the assignment of tuning values take place before accessing it in "prefabs/farm_plants.lua"?

Edited by _zwb

Share this comment


Link to comment
Share on other sites

This is unlikely to happen since it is just a difference in operating sequence. Unless another mod reads PrefabFiles and try to load it before modwrangler.

PrefabFiles is only visited when registering prefabs. There is no difference if you load tuning values before the assignment or after it.

Share this comment


Link to comment
Share on other sites

1 hour ago, Rickzzs said:

There is no difference if you load tuning values before the assignment or after it.

But there is a difference when I changed the order...very strange. And no other mods were enabled

Share this comment


Link to comment
Share on other sites



Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
  • Create New...