MissSora22 Posted May 17, 2019 Share Posted May 17, 2019 I have brought cactus to Hamlet with my mod and now I'm trying to get them to bloom in the humid season. I tried in modmain: GetSeasonManager = GLOBAL.GetSeasonManager local function cactus_H(inst) if GetSeasonManager() and GetSeasonManager():IsHumidSeason() then inst.AnimState:PlayAnimation("grow_flower") inst.AnimState:PushAnimation("idle_flower", true) inst.has_flower = true else inst.AnimState:PlayAnimation("grow") inst.AnimState:PushAnimation("idle", true) inst.has_flower = false end inst.Physics:SetActive(true) end AddPrefabPostInit("cactus", cactus_H) local function OnEntityWake_H(inst) if GetSeasonManager() and GetSeasonManager():IsHumidSeason() then if inst.components.pickable and inst.components.pickable.canbepicked then inst.AnimState:PlayAnimation("idle_flower", true) inst.has_flower = true else inst.AnimState:PlayAnimation("empty", true) inst.has_flower = false end else if inst.components.pickable and inst.components.pickable.canbepicked then inst.AnimState:PlayAnimation("idle", true) else inst.AnimState:PlayAnimation("empty", true) end inst.has_flower = false end end AddPrefabPostInit("cactus", OnEntityWake_H) It`s not working, can someone see were the problem is? Thank you Link to comment Share on other sites More sharing options...
Ultroman Posted May 18, 2019 Share Posted May 18, 2019 You have two AddPrefabPostInit for one prefab. Why? What you're doing here, is making both of those functions execute after the entity has been initialized. That could be the crux of the problem. To help you figure out exactly why it's not working, I'd need either your log (if it has an error in it) or the entire mod in a zip. Link to comment Share on other sites More sharing options...
MissSora22 Posted May 18, 2019 Author Share Posted May 18, 2019 I chanced it into one AddPrefabPostInit, but still no flowers. I can't find any errors in the log with connect to the cactus prefab, but perhaps I overlooked it. Here are the mod and log. My Mod.zip log.txt Link to comment Share on other sites More sharing options...
Ultroman Posted May 19, 2019 Share Posted May 19, 2019 What you're doing only affects the cactus when it's being created, so your code is only run at start-up. What you need to do, is replace the onregenfn being passed to the pickable component, and the OnEntityAwake function being put on the cactus prefab. This should work: modmain.lua Spoiler local function cactus_H(inst) -- Replace OnEntityAwake, which normally reacts to summer season. inst.OnEntityWake = function(inst) if GetSeasonManager() and GetSeasonManager():IsHumidSeason() then if inst.components.pickable and inst.components.pickable.canbepicked then inst.AnimState:PlayAnimation("idle_flower", true) inst.has_flower = true else inst.AnimState:PlayAnimation("empty", true) inst.has_flower = false end else if inst.components.pickable and inst.components.pickable.canbepicked then inst.AnimState:PlayAnimation("idle", true) else inst.AnimState:PlayAnimation("empty", true) end inst.has_flower = false end end -- Replace onregenfn, which normally reacts to summer season. inst.components.pickable.onregenfn = function(inst) if GetSeasonManager() and GetSeasonManager():IsHumidSeason() then inst.AnimState:PlayAnimation("grow_flower") inst.AnimState:PushAnimation("idle_flower", true) inst.has_flower = true else inst.AnimState:PlayAnimation("grow") inst.AnimState:PushAnimation("idle", true) inst.has_flower = false end inst.Physics:SetActive(true) end end AddPrefabPostInit("cactus", cactus_H) Link to comment Share on other sites More sharing options...
MissSora22 Posted May 19, 2019 Author Share Posted May 19, 2019 It works. Thank you very much. I would like to thank you on the mode page when I make the next update. But only if you are alright with that. Link to comment Share on other sites More sharing options...
Ultroman Posted May 19, 2019 Share Posted May 19, 2019 You're very welcome. Please make sure to make your mod only compatible with Hamlet, since it'll mess up the cacti if the mod is used in SW or DS/RoG. I didn't see if you already did this. Just making sure. 18 minutes ago, MissSora22 said: I would like to thank you on the mode page when I make the next update. But only if you are alright with that. It's far from required, but would be very appreciated. If you feel like it, go ahead Also, I don't know how this works if you turn on the mod and start a game in e.g. SW but make it Hamlet compatible...and what happens if you start in SW and sail to Hamlet in the Seaworthy? Link to comment Share on other sites More sharing options...
MissSora22 Posted May 19, 2019 Author Share Posted May 19, 2019 That is a good idea, I have in the description, that it is for hamlet, but I will try to get it in the mod itself. Link to comment Share on other sites More sharing options...
Ultroman Posted May 19, 2019 Share Posted May 19, 2019 modinfo.lua dont_starve_compatible = false reign_of_giants_compatible = false shipwrecked_compatible = false hamlet_compatible = true Link to comment Share on other sites More sharing options...
MissSora22 Posted May 19, 2019 Author Share Posted May 19, 2019 47 minutes ago, Ultroman said: modinfo.lua dont_starve_compatible = false reign_of_giants_compatible = false shipwrecked_compatible = false hamlet_compatible = true I already tried that, but them the SW recipes I added don`t work anymore. I will try, if I can, to find a way the insert a warning screen like in the beginning of hamlet as it was in beta. Link to comment Share on other sites More sharing options...
Ultroman Posted May 19, 2019 Share Posted May 19, 2019 4 hours ago, MissSora22 said: I already tried that, but then the SW recipes I added don`t work anymore. Really? Which recipes? That has to be fixable. Link to comment Share on other sites More sharing options...
MissSora22 Posted May 19, 2019 Author Share Posted May 19, 2019 In the same mod, directily under the cactus Link to comment Share on other sites More sharing options...
Ultroman Posted May 19, 2019 Share Posted May 19, 2019 Yeah, but...every single one of them? Aha...from recipe.lua -- This has to happen first, since ROG overwrites Vanilla and Shipwrecked overwrites both if SaveGameIndex:IsModeShipwrecked() then valid_recipes = MergeMaps(valid_recipes, Shipwrecked_Recipes) elseif SaveGameIndex:IsModePorkland() then valid_recipes = MergeMaps(valid_recipes, Porkland_Recipes) else valid_recipes = MergeMaps(valid_recipes, Vanilla_Recipes) if rog_enabled then valid_recipes = MergeMaps(valid_recipes, RoG_Recipes) end end I always read it as subsequent if's, not else's. Damn. Well, I'm intrigued, and if I had the time, I'd look into it. This seems like a mod that'll have some problems at some point, but I don't have time to test it. If you find something, please make a thread on the forum. Very interested Link to comment Share on other sites More sharing options...
MissSora22 Posted May 19, 2019 Author Share Posted May 19, 2019 Yes, there might be doubles but since they don`t shop up two times, I found it simpler to be on the save side and add one to many instead of forgetting one. I tried this also: local Recipe = GLOBAL.Recipe local Rec1 = Recipe("saddlehorn", {Ingredient("twigs", 2), Ingredient("boneshard", 2), Ingredient("feather_crow", 1)}, RECIPETABS.TOOLS, TECH.SCIENCE_TWO, {RECIPE_GAME_TYPE.PORKLAND}) But es soon as I turned the dont_starve_compatible = false reign_of_giants_compatible = false shipwrecked_compatible = false hamlet_compatible = true it didn`t work any more Perhabs if we find a solution here, it might also solve a problem with an other mod I started to make. I have a new prefab of a structure there but I cann`t get it into the tabs Link to comment Share on other sites More sharing options...
Recommended Posts
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.