Jump to content

Recommended Posts

I'm creating one of my first mods, Zenny. I decided I should add a config menu so that it can be re-balanced by users. But, when I change a setting, it will crash upon playing as Zenny.

Details:

[00:01:08]: [string "../mods/zenny-dst/scripts/prefabs/zenny.lua"]:79: attempt to index field 'Zenny' (a nil value)
LUA ERROR stack traceback:
    ../mods/zenny-dst/scripts/prefabs/zenny.lua:79 in (upvalue) master_postinit (Lua) <68-105>
    scripts/prefabs/player_common.lua:1602 in (field) fn (Lua) <1264-1626>
    scripts/mainfunctions.lua:258 in () ? (Lua) <247-289>
    =[C]:-1 in (method) SendSpawnRequestToServer (C) <-1--1>
    scripts/mainfunctions.lua:1406 in (local) cb (Lua) <1404-1407>
    scripts/frontend.lua:598 in (method) DoFadingUpdate (Lua) <562-602>
    scripts/frontend.lua:650 in (method) Update (Lua) <610-760>
    scripts/update.lua:92 in () ? (Lua) <33-129>

Custom Config (only part):

{
        name = "ZennyHP",
        label = "Max HP",
        options =
        {
            {description = "Cheating- 450", data = 450},
            {description = "High- 300", data = 300},                
            {description = "Default- 250", data = 250},                                        
            {description = "Old def.- 175", data = 175},
            {description = "Weak- 100", data = 100},    
        },
        default = 250,
    },

Max HP modifier:

inst.components.health:SetMaxHealth(TUNING.Zenny.ZennyHP)

-----------------------------------------------------------------------------------------------------------------------------------

 

So, it has to do with (TUNING.Zenny.ZennyHP). Does that mean I have to add a tag for it?

Files are below.

modinfo.lua

zenny.lua

I think in modmain.lua you can do

TUNING.Zenny.ZennyHP = GetModConfigData("ZennyHP")

You will have to add "local TUNING = GLOBAL.TUNING" in modmain.lua if you haven't already.

If that doesn't work then try changing TUNING.Zenny.ZennyHP to TUNING.ZENNYHP

You can also try looking at some mods with configurable options as examples.

Also I see you tried adding options for other stats, this is possible you just have to do what I said above for those too

for example ZennySanity, in modmain you can add "TUNING.ZENNYSANITY = GetModConfigData("ZennySanity")

and then replace the sanity stat in zenny.lua the same way you did with the health stat.

Hope this helps.

 

3 hours ago, Danielance said:

I think in modmain.lua you can do

TUNING.Zenny.ZennyHP = GetModConfigData("ZennyHP")

You will have to add "local TUNING = GLOBAL.TUNING" in modmain.lua if you haven't already.

If that doesn't work then try changing TUNING.Zenny.ZennyHP to TUNING.ZENNYHP

You can also try looking at some mods with configurable options as examples.

Also I see you tried adding options for other stats, this is possible you just have to do what I said above for those too

for example ZennySanity, in modmain you can add "TUNING.ZENNYSANITY = GetModConfigData("ZennySanity")

and then replace the sanity stat in zenny.lua the same way you did with the health stat.

Hope this helps.

 

Thanks! It worked perfectly. I had to make"TUNING.ZENNYSANITY = GetModConfigData("ZennySanity")" in modmain into "TUNING.ZENNYSANITY = (GetModConfigData("ZennySanity"))" though.
Thanks a ton for the help.

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