Jump to content

Prefab Overwriting


Navi

Recommended Posts

Hi there, I scoured the tutorials and forums for this and though I'm sure it's there somewhere, I couldn't find it. Apologies if it's quite simple.

 

Part of my custom character is the ability to eat a regular item, Flint, just like WX can eat Gears.

 

I have the duplicated and modified flint.lua completed, I'm pretty sure, but my question is simply where and how is the Mod folder structured to "overwrite" the original game file for flint.lua? As the change isn't registering in the Mod folders I have tried (and I'd like to publish the mod, rather than just alter my own personal flint.lua file).

 

Currently I have the modified flint.lua sitting in the following tree;

 

dont_starve/Mods/EdibleFlint/scripts/prefabs

 

Thank you!

 

P.S. With the way I've done it above, to utilize the character's ability I'd have to make 2 separate downloadable mods for the Character and then the Edible Flint. Is there a way to include them both in the same mod folder so I can make them one singular mod?

Link to comment
Share on other sites

Hi there, I scoured the tutorials and forums for this and though I'm sure it's there somewhere, I couldn't find it. Apologies if it's quite simple.

 

Part of my custom character is the ability to eat a regular item, Flint, just like WX can eat Gears.

 

I have the duplicated and modified flint.lua completed, I'm pretty sure, but my question is simply where and how is the Mod folder structured to "overwrite" the original game file for flint.lua? As the change isn't registering in the Mod folders I have tried (and I'd like to publish the mod, rather than just alter my own personal flint.lua file).

 

Currently I have the modified flint.lua sitting in the following tree;

 

dont_starve/Mods/EdibleFlint/scripts/prefabs

 

Thank you!

 

P.S. With the way I've done it above, to utilize the character's ability I'd have to make 2 separate downloadable mods for the Character and then the Edible Flint. Is there a way to include them both in the same mod folder so I can make them one singular mod?

 

Simple answer, don't overwrite prefabs. Overwriting original game files will lead to compatibility issues with other mods, Use the AddPrefabPostInit function instead, so your functionality gets added to the flint without overwriting it's core functionality.

Link to comment
Share on other sites

For examples on using the function described above, look into other mods tweaking game prefabs.

 

Basically, you need to do this in modmain.lua:

 

local function NewFlint(inst)

    inst:AddComponent("edible")

    print("it worked! =D")

end

 

AddPrefabPostInit("flint",NewFlint)

Link to comment
Share on other sites

For examples on using the function described above, look into other mods tweaking game prefabs.

 

Basically, you need to do this in modmain.lua:

 

local function NewFlint(inst)

    inst:AddComponent("edible")

    print("it worked! =D")

end

 

AddPrefabPostInit("flint",NewFlint)

 

Since this question I have is relevant, I'll ask it here.

How do you REMOVE tags from a prefab?

I want to remove the tag for nightmare creatures that makes them not trigger tooth traps, and overwriting the prefab the "old" way doesn't work.

 

I know it still uses AddPrefabPostInit, but what next..?

Link to comment
Share on other sites

Since this question I have is relevant, I'll ask it here.

How do you REMOVE tags from a prefab?

I want to remove the tag for nightmare creatures that makes them not trigger tooth traps, and overwriting the prefab the "old" way doesn't work.

 

I know it still uses AddPrefabPostInit, but what next..?

 

inst:RemoveTag("notraptrigger")

 

:3

 

(I think there is a mod for that already)

(not sure if that is the actual tag name)

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