Ultroman Posted August 29, 2018 Share Posted August 29, 2018 (edited) Hello. I really hope someone can help me answer some questions regarding DST modding. It seems to be things I should be able to find answers to, but I've been searching all over, and cannot find answers to these specific questions. I have a small collection of mods that I've built, and none of them add anything new, they only edit variables in various components (on both prefabs and players), recipes and states. Since the caves update came out, things have changed quite a bit. Before today, ALL my mods were set up with "all_clients_require_mod = false" and "client_only_mod = false", because as I understood it, the server needed to be in control of all these kinds of things. Question 1: For example, I have a mod called Fishing Buddy, which changes various variables of the ponds. Before caves, I wrapped all my code like this, to stop clients from executing the code: if GLOBAL.TheNet and GLOBAL.TheNet:GetIsServer() then AddPrefabPostInit(blabla) AddPlayerPostInit(blabla) end When caves came along, this would crash the cave shard, unless I removed the AddPrefabPostInit which changed "pond_cave". I saw that other mods which were doing the same kind of thing, simply didn't have the GetIsServer() check, so I removed that, and now it works. Did I never actually need to have this check for these two functions? Question 2: For another mod, Resurrection Tuner, I change the recipe for Telltale Heart, using settings the user picks, like this: if GLOBAL.TheNet and GLOBAL.TheNet:GetIsServer() then AddRecipe("reviver", { stuff }) end This didn't work in worlds created with caves in them, for some reason. The recipe wasn't changed, and when you tried creating one, it would run the crafting animation, but it wouldn't create anything or eat the materials. I saw that someone posted about setting all_clients_require_mod to true, would fix "some issues", but I cannot find more elaborate information on what these issues are. I tried it, and I also removed the GetIsServer() check, and it fixed the problem. Of these three functions I've used in the two code snippets, is it only AddRecipe that needs all_clients_require_mod set to true? I just tested, and it does it in fact need that variable set to true. Just removing the GetIsServer() call isn't enough. Obviously, I would love it if I could do without setting all_clients_require_mod to true. Question 3: Taking into account the previous questions, is there anything special when using "addState"? Because my Fishing Buddy mod changes a state, to stop the player from ever losing his fishing rod while fishing. I do this within an AddPlayerPostInit call. Question 4: This code still seems to work perfectly, even while in a cave. How is that possible, given the troubles mentioned in the other questions? Shouldn't I have to change something in builder_replica.lua or player_classified as well? And why does it still work when the GetIsServer() call is there, when the other mods are having trouble? local function EvaluateTechTreesDST(self) -- lots of code end local function ChangeBuilderDST(player_inst) if player_inst.components.builder then player_inst.components.builder.EvaluateTechTrees = EvaluateTechTreesDST end end if _G.TheNet and _G.TheNet:GetIsServer() then AddPlayerPostInit(ChangeBuilderDST) end I don't have a setup right now, that allows me to test on a dedicated server on my development PC, so I cannot properly test whether these only work for me as the server or also for the clients. It tries to connect, but disconnects me. Anyway, I thought it would be faster, if one of you fine people could clear this up for me, since I can't seem to find the answers anywhere. Thanks in advance! Sincerely, Ultroman the Tacoman Edited August 29, 2018 by Ultroman Link to comment https://forums.kleientertainment.com/forums/topic/94955-mods-and-caves-please-help/ Share on other sites More sharing options...
Lumina Posted August 29, 2018 Share Posted August 29, 2018 In most cases, when you have issues in world with caves, but your mod works fine for you in world without caves, it's linked to problems related to client side. When you host a server without cave, you are the host. When you host a server with caves, join another server, or are in a dedicated server, you are the client. One possibility is that your mods were working fine for you since you were always the host. But if it's the case, there would have been trouble for players joining server with your mods, since they were client. And it doesn't seems to be the case ? Link to comment https://forums.kleientertainment.com/forums/topic/94955-mods-and-caves-please-help/#findComment-1078720 Share on other sites More sharing options...
Ultroman Posted August 29, 2018 Author Share Posted August 29, 2018 (edited) Many thanks for the reply Yes, I've read your similar answers around here, and have been using the information you provided, to poke around my mods to see what works with and without caves, to see both the server and client experiences. This is why I'm asking about the GLOBAL.TheNet:GetIsServer() calls and all_clients_require_mod setting, and which of those three game functions require them. I'm not sure that testing with and without caves, is exactly the same as an actual server/client relationship, but it's all I've got atm. The mods seem to work now, both with and without caves. Apparently AddRecipe MUST have all_clients_require_mod set to true now, in order to work with caves. It did not need this before caves were introduced, because the clients got the new recipe just fine before. It's annoying to have to set all_clients_require_mod to true, but I've seen a few other recipe mods also do it, and those that don't, are probably just not up-to-date. Question 3, about addState, is mostly because it's very time-consuming to test, since there's RNG involved, and also it would be nice to know these things for sure. Question 4 comes from genuine disbelief that it works, when some mods straight up don't work with the GLOBAL.TheNet:GetIsServer() checks surrounding the code. I'm thinking, that maybe because the EvaluateTechTrees function in builder.lua is not in builder_replica.lua, it works for everyone, because it's only a client function. If you know any of this for sure, I'd love to hear it, so I can make the appropriate changes to my other mods, which use similar methods. Thanks again! Sincerely, Ultroman the Tacoman Edited August 29, 2018 by Ultroman Link to comment https://forums.kleientertainment.com/forums/topic/94955-mods-and-caves-please-help/#findComment-1078725 Share on other sites More sharing options...
Lumina Posted August 29, 2018 Share Posted August 29, 2018 My knowledge of these things is limited. I know that most components should be server side only (with maybe the exception of the replica ?). Usually, when something is before this line in a prefab, it's needed client side. if not TheWorld.ismastersim then return inst end When it's after, it's server side and shouldn't be accessible for client. But outside of this i don't know the exact rules. I hope someone will be able to help you more with this. Link to comment https://forums.kleientertainment.com/forums/topic/94955-mods-and-caves-please-help/#findComment-1078744 Share on other sites More sharing options...
Ultroman Posted August 29, 2018 Author Share Posted August 29, 2018 I hope so, too. Thanks for your help so far At least my mods seem to work now, but it would be nice to have these "rules" defined more clearly. Hopefully simplex or someone else knowledgeable will be able to chime in. Link to comment https://forums.kleientertainment.com/forums/topic/94955-mods-and-caves-please-help/#findComment-1078899 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