Jump to content

Two related mod questions


Nycidian

Recommended Posts

I believe that to run a prefab file it is referenced in the modmain.lua like so

PrefabFiles = {	"charlie",}

So how to you get other files in other folders to automatically load say a custom component file?

 

On a somewhat related note:

 

I know how to call a component file, take sanity as an example.

 

inst.component.sanity.<variable>

 

Or

 

inst.component.sanity:<function>

 

How do you call a non component file directly?

 

Link to comment
Share on other sites

Any other file like widgets, brains, stategraphs, maps... is loaded when needed. You can see examples all over the code and you don't have to do anything different. Pretend they weren't modfiles.

Same goes for accessing them. You do it like the vanilla files do, i.e. inst.sg to get the stategraph.

Link to comment
Share on other sites

If you're adding a component like hunger - e.g. a property of something, just use "AddComponent" the same as any of Klie's components. it'll look in the component directory (yours, then the games') folders for a matching .lua file.

 

If you want to add something to the world - like "hounded" or "basehassler" (deerclops) - add them to the prefab "forest". Since this will already be defined, just use a postinit function to add more to the entity (this also works for anything already define, like pigmen or perds)

function forestpostinit(inst)	inst:AddComponent("my_new_component")endAddPrefabPostInit("forest", forestpostinit)

As for how to call non-component files directly... you generally don't. AddComponent grabs from the component directory. SetStategraph looks in the stategraphs directory for the name provided.

The two exceptions I've seen are brains and behaviors. Both of these use "require" and they seem rooted at your mod's folder. You can likely load utility files that way if your stuff doesn't fall into one of the pre-supported types.

Link to comment
Share on other sites

If you're adding a component like hunger - e.g. a property of something, just use "AddComponent" the same as any of Klie's components. it'll look in the component directory (yours, then the games') folders for a matching .lua file.

 

If you want to add something to the world - like "hounded" or "basehassler" (deerclops) - add them to the prefab "forest". Since this will already be defined, just use a postinit function to add more to the entity (this also works for anything already define, like pigmen or perds)

function forestpostinit(inst)	inst:AddComponent("my_new_component")endAddPrefabPostInit("forest", forestpostinit)

As for how to call non-component files directly... you generally don't. AddComponent grabs from the component directory. SetStategraph looks in the stategraphs directory for the name provided.

The two exceptions I've seen are brains and behaviors. Both of these use "require" and they seem rooted at your mod's folder. You can likely load utility files that way if your stuff doesn't fall into one of the pre-supported types.

Thank you so much, "AddComponent" is what I was looking for.  

 

While I really do love this game and modding it,  some of the features of modding this game are very opaque. I'm glad people are willing to help. Thank you to Malacath as well for trying to help.

 

:)

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