ELEMENTALCRAFTER009 Posted February 12, 2016 Share Posted February 12, 2016 (edited) Alright, before the new caves update for DST, everything was working perfectly and now part of my characters modmain is causing the game to run out of memory. It has something to do with the pickable component, which I have no idea if it changed from the last version of the game local function newOnPickedFn(inst, picker) if picker and picker.components.sanity then picker.components.sanity:DoDelta(-TUNING.SANITY_TINY) end inst:Remove() end local function flowerPostPrefab(inst) inst.components.pickable.onpickedfn = newOnPickedFn end AddPrefabPostInit("flower", flowerPostPrefab) local function newOnPickedFn(inst, picker) if picker and picker.components.sanity then picker.components.sanity:DoDelta(TUNING.SANITY_MED) end inst:Remove() end local function evilFlowerPostPrefab(inst) inst.components.pickable.onpickedfn = newOnPickedFn end AddPrefabPostInit("flower_evil", flowerPostPrefab) here's my log too. client_log.txt Edited February 12, 2016 by ELEMENTALCRAFTER009 Link to comment Share on other sites More sharing options...
MF99K Posted February 12, 2016 Share Posted February 12, 2016 Out of memory errors usually mean that the game is trying to do something over and over again in a loop. When I've gotten these errors before, it's been a compiling issue with my anim files, but your log looks different. the out of memory issue seems to be related to something RakNet is trying to do over and over and over again and not your mod necessarily. what exactly are you trying to do with this code? Link to comment Share on other sites More sharing options...
ELEMENTALCRAFTER009 Posted February 12, 2016 Author Share Posted February 12, 2016 Just now, mf99k said: Out of memory errors usually mean that the game is trying to do something over and over again in a loop. When I've gotten these errors before, it's been a compiling issue with my anim files, but your log looks different. the out of memory issue seems to be related to something RakNet is trying to do over and over and over again and not your mod necessarily. what exactly are you trying to do with this code? Whenever the player picks a flower, then the sanity will decrease by 5. An opposite effect is applied for the evil flower. Link to comment Share on other sites More sharing options...
MF99K Posted February 12, 2016 Share Posted February 12, 2016 6 minutes ago, ELEMENTALCRAFTER009 said: Whenever the player picks a flower, then the sanity will decrease by 5. An opposite effect is applied for the evil flower. and this is in the character's prefab file? Link to comment Share on other sites More sharing options...
ELEMENTALCRAFTER009 Posted February 12, 2016 Author Share Posted February 12, 2016 (edited) 1 minute ago, mf99k said: and this is in the character's prefab file? No, it's in the modmain as an AddPrefabPostInit. Edited February 12, 2016 by ELEMENTALCRAFTER009 Link to comment Share on other sites More sharing options...
MF99K Posted February 12, 2016 Share Posted February 12, 2016 ok so my computer isn't letting me post anything right now for some annoying reason so I'm gonna try this again what I've gotten to work before with character mods that have different sanity effects with flowers is copy the flower prefabs from the base game into the character mod, give the character a custom tag, and change the picked function to something like this: local function newOnPickedFn(inst, picker) if picker and picker.components.sanity and not picker.HasTag:("customtagexample") then picker.components.sanity:DoDelta(TUNING.SANITY_MED) elseif picker.HasTag:("customtagexample") then picker.components.sanity:DoDelta(-TUNING.SANITY_MED) end inst:Remove() end The Warper character mod on steam is like this if you need a better example of how to code it. Link to comment Share on other sites More sharing options...
ELEMENTALCRAFTER009 Posted February 12, 2016 Author Share Posted February 12, 2016 17 minutes ago, mf99k said: ok so my computer isn't letting me post anything right now for some annoying reason so I'm gonna try this again what I've gotten to work before with character mods that have different sanity effects with flowers is copy the flower prefabs from the base game into the character mod, give the character a custom tag, and change the picked function to something like this: local function newOnPickedFn(inst, picker) if picker and picker.components.sanity and not picker.HasTag:("customtagexample") then picker.components.sanity:DoDelta(TUNING.SANITY_MED) elseif picker.HasTag:("customtagexample") then picker.components.sanity:DoDelta(-TUNING.SANITY_MED) end inst:Remove() end The Warper character mod on steam is like this if you need a better example of how to code it. [string "../mods/Welginny - DST/modmain.lua"]:73: '<name>' expected near '(' This is in the log even though there is a name in the code local function flowerPostPrefab(inst) inst:AddTag("RemoveSanity") end local function evilFlowerPostPrefab(inst) inst:AddTag("AddSanity") end local function newOnPickedFn(inst, picker) if picker and picker.components.sanity and not picker.HasTag:("AddSanity") then --This line picker.components.sanity:DoDelta(TUNING.SANITY_MED) elseif picker.HasTag:("RemoveSanity") then picker.components.sanity:DoDelta(-TUNING.SANITY_MED) end inst:Remove() end AddPrefabPostInit("flower", flowerPostPrefab) AddPrefabPostInit("flower_evil", flowerPostPrefab) Link to comment Share on other sites More sharing options...
Muche Posted February 12, 2016 Share Posted February 12, 2016 (edited) The biggest change in the recent update is that when you host the game you are no longer the server, you are the client that connects to a mini dedicated server. Thus when investigating bugs in your mod you need to check both client_log and server_log (I have mine at Documents\Klei\DoNotStarveTogether\Cluster_1\Master\server_log.txt). The message RakNet detected a missing replica usually indicates network synchronization errors. My guess is that your mod previously worked on hosted game only and not on dedicated server. Try enclosing the code in modmain that is not meant to run on the client in if GLOBAL.TheNet and GLOBAL.TheNet:GetIsServer() then -- your server only code end Edited February 12, 2016 by Muche Link to comment Share on other sites More sharing options...
ELEMENTALCRAFTER009 Posted February 12, 2016 Author Share Posted February 12, 2016 5 minutes ago, Muche said: The biggest change in the recent update is that when you host the game you are no longer the server, you are the client that connects to mini dedicated server. Thus when investigating bugs in your mod you need to check both client_log and server_log (I have mine at Documents\Klei\DoNotStarveTogether\Cluster_1\Master\server_log.txt). The message RakNet detected a missing replica usually indicates network synchronization errors. My guess is that your mod previously worked on hosted game only and not on dedicated server. Try enclosing the code in modmain that is not meant to run on the client in if GLOBAL.TheNet and GLOBAL.TheNet:GetIsServer() then -- your server only code end Would this how you place it? if GLOBAL.TheNet and GLOBAL.TheNet:GetIsServer() then local function flowerPostPrefab(inst) inst:AddTag("RemoveSanity") end local function evilFlowerPostPrefab(inst) inst:AddTag("AddSanity") end local function newOnPickedFn(inst, picker) if picker and picker.components.sanity and not picker.HasTag:("AddSanity") then picker.components.sanity:DoDelta(TUNING.SANITY_MED) elseif picker.HasTag:("RemoveSanity") then picker.components.sanity:DoDelta(-TUNING.SANITY_MED) end inst:Remove() end AddPrefabPostInit("flower", flowerPostPrefab) AddPrefabPostInit("flower_evil", flowerPostPrefab) end Link to comment Share on other sites More sharing options...
Muche Posted February 12, 2016 Share Posted February 12, 2016 Yes. Although looking at it, there is a mismatch in the new newOnPickedFn - it checks AddSanity/RemoveSanity tags on the picker, not on the flower that postprefabinits are giving it to. Link to comment Share on other sites More sharing options...
ELEMENTALCRAFTER009 Posted February 12, 2016 Author Share Posted February 12, 2016 (edited) 38 minutes ago, Muche said: Yes. Although looking at it, there is a mismatch in the new newOnPickedFn - it checks AddSanity/RemoveSanity tags on the picker, not on the flower that postprefabinits are giving it to. How would you put to refer to the flower/evil flower prefab with the tag in the function? Edited February 12, 2016 by ELEMENTALCRAFTER009 Link to comment Share on other sites More sharing options...
ELEMENTALCRAFTER009 Posted February 12, 2016 Author Share Posted February 12, 2016 (edited) 36 minutes ago, ELEMENTALCRAFTER009 said: How would you put to refer to the flower/evil flower prefab with the tag in the function? Or am I just confused on what to do? Edited February 12, 2016 by ELEMENTALCRAFTER009 Link to comment Share on other sites More sharing options...
Muche Posted February 12, 2016 Share Posted February 12, 2016 Honestly, the code in the first post looked good to me (as it is almost identical to what the game is doing currently, just with values of gained sanity changed). For example, checking player's tag would be useful if the amount of sanity gained depended on which character picked the flower up; tags on flowers would be useful if they were added to other prefabs as well. I feel like in this case they are not needed. Link to comment Share on other sites More sharing options...
ELEMENTALCRAFTER009 Posted February 13, 2016 Author Share Posted February 13, 2016 3 hours ago, Muche said: Honestly, the code in the first post looked good to me (as it is almost identical to what the game is doing currently, just with values of gained sanity changed). For example, checking player's tag would be useful if the amount of sanity gained depended on which character picked the flower up; tags on flowers would be useful if they were added to other prefabs as well. I feel like in this case they are not needed. Alternatively this function appears to do exactly the same thing, but goes in the character prefab. Fixed! if data and data.object.prefab == "flower" and inst.components.sanity then inst.components.sanity:DoDelta(-TUNING.SANITY_MED) elseif data and data.object.prefab == "flower_eveil" and inst.components.sanity then inst.components.sanity:DoDelta(TUNING.SANITY_MED) end end) Link to comment 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