Jump to content

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

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)

Edited by Mobbstar

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!

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...