Nycidian Posted October 17, 2013 Share Posted October 17, 2013 I believe that to run a prefab file it is referenced in the modmain.lua like soPrefabFiles = { "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 https://forums.kleientertainment.com/forums/topic/28823-two-related-mod-questions/ Share on other sites More sharing options...
Malacath Posted October 17, 2013 Share Posted October 17, 2013 (edited) 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. Edited October 17, 2013 by Malacath Link to comment https://forums.kleientertainment.com/forums/topic/28823-two-related-mod-questions/#findComment-345007 Share on other sites More sharing options...
realitymeltdown Posted October 17, 2013 Share Posted October 17, 2013 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 https://forums.kleientertainment.com/forums/topic/28823-two-related-mod-questions/#findComment-345008 Share on other sites More sharing options...
Nycidian Posted October 17, 2013 Author Share Posted October 17, 2013 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 https://forums.kleientertainment.com/forums/topic/28823-two-related-mod-questions/#findComment-345015 Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now