Jump to content

Custom Character Some Crashes On Start Up


Recommended Posts

Hi, all. I took a break from modding for about a year, then decided to get back into it once I heard Hamlet was out. I tried to load up the WIP mod I was making, but have ran into some errors. I'm rusty, too, but trying to relearn everything.

 

To begin with, my character functioned just fine last time I played the game - a year+ ago.

 

If I attempt to load the character in Don't Starve (no compatibility boxes checked), I get this error:

[00:00:43]: scripts/mainfunctions.lua(961,1) ...nt_starve/data/../mods/Bobbi/scripts/prefabs/bob.lua:177: attempt to index field 'moisture' (a nil value)

Line 177 contains this:

    inst.components.moisture.maxMoistureRate = 1.25

I remember this worked just fine. All I did was make it so the character got wetter faster. The bob.lua is the prefab file for the custom character.

 

If I attempt to load Don't Starve: Reign of Giants with the character (no compatibility boxes checked), I get the error:

[00:01:11]: scripts/mainfunctions.lua(961,1) ...starve/data/../mods/Bobbi/scripts/prefabs/hassli.lua:221: variable 'MakePoisonableCharacter' is not declared

That was a new one on me. So, I found and added

    MakePoisonableCharacter(inst)

to line 221 of my prefab. The hassli.lua it is referring to is a copy of Chester called Hassli, and everything else seems identical between Chester and Hassli's prefabs. I get the same error when loading the new file with the MakePoisonableCharacter(inst) line added.

 

If I attempt to load Shipwrecked...

The mod is fine, so hooray for small mercies.

 

If I attempt to load Hamlet (no compatibility boxes checked), I get this error:

[00:01:22]: scripts/mainfunctions.lua(961,1) ...starve/data/../mods/Bobbi/scripts/prefabs/hassli.lua:229: calling 'CollidesWith' on bad self (number expected, got nil)

I checked Chester, and collision was identical, but it did seem I had missed:

    inst.Physics:CollidesWith(COLLISION.WAVES)

So, I added it to the Collision section.

    --print("   Collision")
    inst.Physics:SetCollisionGroup(COLLISION.CHARACTERS)

    inst.Physics:ClearCollisionMask()
    inst.Physics:CollidesWith(COLLISION.WORLD) 
                                           [This is line 229]
    inst.Physics:CollidesWith(COLLISION.OBSTACLES)
    inst.Physics:CollidesWith(COLLISION.CHARACTERS)
    inst.Physics:CollidesWith(COLLISION.WAVES)

But, when I attempted to load the mod again, I got the same error. I understand I did nothing to actually help the issue, but I have not noticed a value attached to line 229 in Chester's prefab.

 

A lot of this I have the vague feeling is newbie stuff, but I simply can't remember. Haven't touched this sort of stuff in over a year.  Hope someone can point me in the right direction. I'll attach the mod so anyone who is interested can have a dig through its guts.

Bobbi.7z

Link to comment
Share on other sites

It's all because of the vast differences between the DLCs. There is no moisture component in DS, only in RoG, SW and Hamlet.

Same with the CollidesWith thing. chester.lua for DS only has these lines in it:

inst.Physics:SetCollisionGroup(COLLISION.CHARACTERS)
inst.Physics:ClearCollisionMask()
inst.Physics:CollidesWith(COLLISION.WORLD)
inst.Physics:CollidesWith(COLLISION.OBSTACLES)
inst.Physics:CollidesWith(COLLISION.CHARACTERS)

So, not the COLLISION.WAVES thing, because there are no waves in DS or RoG.

And it's the same with MakePoisonableCharacter, which is only available in SW and Hamlet.

If you want your character to be compatible with all different DLCs, you have to do some things only when the right DLCs are used. You can use the following code to produce boolean variables saying which DLCs are active, and then wrap the "offending" lines in appropriate if-statements.

local _G = GLOBAL

local IsRoG = _G.IsDLCEnabled(_G.REIGN_OF_GIANTS)
local IsSW = _G.IsDLCEnabled(_G.CAPY_DLC)
local IsHamlet = _G.IsDLCEnabled(_G.PORKLAND_DLC)

 

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