Jump to content

(LUA question) Writing a tuning file for my mod


Recommended Posts

I am writing a rather large mod so I decided to it would be a good idea to collect the tuning elements into a single file.

So I found the don't stave tuning.lua, skimmed through it, and wrote my own.

However my mod no longer loads. There isn't an error message it just freezes (the indicator that the lua is bad)

A look at the crash log.txt shows that it was caused by the first call to the 'MOD_TUNING' saying that it was a nil value.

Attached is the tuning file. (in the mod it is a .lua file)

In the rest of the mod I call the tuning like this:

health = MOD_TUNING.FOOD_HEALTH 

Any help is much appreciated.

mod_tuning.txt

Link to comment
Share on other sites

I can't look at your issue in detail right now, but look at "elinor", that mod has a tuning file too.

 

EDIT: I took a brief glance at your file (txt).

Why are you using a function to define the table? Can't you just define it straight away?

Did you try to return the table? (stupid idea, I know)

Link to comment
Share on other sites

I can't look at your issue in detail right now, but look at "elinor", that mod has a tuning file too.

 

EDIT: I took a brief glance at your file (txt).

Why are you using a function to define the table? Can't you just define it straight away?

Did you try to return the table? (stupid idea, I know)

Thanks for the help. after looking at the elinor mod's tuning file I saw that they just created more fields in the global tuning table.

It's working great now. Thanks for the help!

 

For people reading this question later this is how I did it.

In your tuning file:

TUNING.FOODITEM = TUNING.FOODITEM or {} -- creates a blank entry in the tuning file-- set all the values you wantTUNING.FOODITEM.HEALTH = 5 TUNING.FOODITEM.HUNGER = 1TUNING.FOODITEM.SANITY = 15

Add this line to the top of your modmain.lua:

modimport ("scripts/*tuning file name here*.lua") 

Then to get the values in your code later:

inst:AddComponent("edible")inst.components.edible.healthvalue = TUNING.FOODITEM.HEALTHinst.components.edible.hungervalue = TUNING.FOODITEM.HUNGERinst.components.edible.sanityvalue = TUNING.FOODITEM.SANITY 

Simple as that!

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

Please be aware that the content of this thread may be outdated and no longer applicable.

×
  • Create New...