Eir Posted January 15, 2015 Share Posted January 15, 2015 I am working on a character mod based on the Little Red Riding Hood. I want her to transform to a certain monster form when she reaches a certain wetness level/threshold during a rainstorm. However, I have no idea where to start. Any help would be much appreciated. I have attached my character lua, if you would like to look.wred.lua Link to comment https://forums.kleientertainment.com/forums/topic/49197-transform-below-wetnessmoisture-threshold/ Share on other sites More sharing options...
rezecib Posted January 16, 2015 Share Posted January 16, 2015 @Eir, Well, wetness doesn't really exist yet, as that's a part of RoG. How exactly do you want it to interact with rain? Link to comment https://forums.kleientertainment.com/forums/topic/49197-transform-below-wetnessmoisture-threshold/#findComment-602479 Share on other sites More sharing options...
Eir Posted January 17, 2015 Author Share Posted January 17, 2015 (edited) @rezecibYeah, as you can tell, I posted this question in the wrong section. I would delete this topic if I knew how. This question was intended for Don't Starve ROG. But now that you know this, if you can contribute anything to my question, I would appreciate it very much. To clarify, if my rainometer hits a certain number, I want my character to transform. Then, if daybreak occurs, I would like my character to detransform. Edited January 17, 2015 by Eir Link to comment https://forums.kleientertainment.com/forums/topic/49197-transform-below-wetnessmoisture-threshold/#findComment-602801 Share on other sites More sharing options...
DarkXero Posted January 17, 2015 Share Posted January 17, 2015 Characters have a moisture component. When moisture changes with a DoDelta, the moisturechange event gets pushed. So you can listen to the moisturechange event. Or you can make a transformation component that self updates and checks moisture via self.inst.components.moisture:GetMoisture(). Or a separate periodic task to check. Link to comment https://forums.kleientertainment.com/forums/topic/49197-transform-below-wetnessmoisture-threshold/#findComment-602845 Share on other sites More sharing options...
Eir Posted January 22, 2015 Author Share Posted January 22, 2015 Characters have a moisture component. When moisture changes with a DoDelta, the moisturechange event gets pushed. So you can listen to the moisturechange event. Or you can make a transformation component that self updates and checks moisture via self.inst.components.moisture:GetMoisture(). Or a separate periodic task to check.@DarkXero I tried to listen for moisture change event, but after I update my mods ingame, the game closes itself when I hit the "apply" button. In my character fn in my LUA file, I put: inst:ListenForEvent("moisturechange", function() RainCheck(inst) end, GetWorld()) Outside of my fn, I put a raincheck function:local function RainCheck(inst) self.inst.components.moisture:GetMoisture() local transform_moisture_threshold = TUNING.WRED.TRANSFORM_MOISTURE_THRESHOLD-- can be retrieved from TUNING inst.old_moisture_OnUpdate = inst.components.moisture.OnUpdate inst.components.moisture.OnUpdate = function(dt) inst:old_moisture_OnUpdate(dt) local moisture = inst.components.moisture:GetMoisture() if moisture > transform_moisture_threshold then TurnMonster(inst) elseif moisture <= transform_moisture_threshold then inst.AnimState:SetBuild("wred") end endend As well as my transformation function:local function TurnMonster(inst) inst.AnimState:SetBuild("wredmonster") inst.SoundEmitter:PlaySound("dontstarve/wilson/death") inst.SoundEmitter:PlaySound("dontstarve/characters/willow/death_voice") inst.AnimState:PlayAnimation("amulet_rebirth") inst.SoundEmitter:PlaySound("dontstarve/common/rebirth_amulet_raise") TheCamera:SetDistance(14) inst.components.sanity:DoDelta(TUNING.WRED_MONSTER_SANITYPENALTY) inst.components.talker:Say(SayRandom(TUNING.WRED_TURNMONSTER))end Note: I have a separate tuning file.Please, tell me if I have made any mistakes. Link to comment https://forums.kleientertainment.com/forums/topic/49197-transform-below-wetnessmoisture-threshold/#findComment-604891 Share on other sites More sharing options...
DarkXero Posted January 23, 2015 Share Posted January 23, 2015 inst.ismonster = false inst:ListenForEvent("moisturechange", RainCheck) local function RainCheck(inst, data) local threshold = TUNING.WRED.TRANSFORM_MOISTURE_THRESHOLD if not inst.ismonster and (data.new > threshold) then TurnMonster(inst) elseif inst.ismonster and (data.new <= threshold) then inst.AnimState:SetBuild("wred") end end Link to comment https://forums.kleientertainment.com/forums/topic/49197-transform-below-wetnessmoisture-threshold/#findComment-605035 Share on other sites More sharing options...
Eir Posted January 28, 2015 Author Share Posted January 28, 2015 inst.ismonster = falseinst:ListenForEvent("moisturechange", RainCheck)local function RainCheck(inst, data) local threshold = TUNING.WRED.TRANSFORM_MOISTURE_THRESHOLD if not inst.ismonster and (data.new > threshold) then TurnMonster(inst) elseif inst.ismonster and (data.new <= threshold) then inst.AnimState:SetBuild("wred") endend Thanks for contributing to my forum post so far. However, the codes you posted did not work. After I updated my mods ingame, the game freezes for a second before automatically closing down. I want to make sure that I did not make a mistake. Would you mind checking my attached files for any coding mistakes? wred.luatuning_wred.lualog.txt Link to comment https://forums.kleientertainment.com/forums/topic/49197-transform-below-wetnessmoisture-threshold/#findComment-606917 Share on other sites More sharing options...
DarkXero Posted January 28, 2015 Share Posted January 28, 2015 (edited) self.inst.components.moisture:GetMoisture()in TurnMonster() has to go. For starters, there is no self. Second, that returns a number and you don't use it for anything. The log line 6084 says there is a build being added twice. Check your wredmonster.zip to see if it has a wred ID. What's up with:inst:DoPeriodicTask(1/10, function() RainCheck(inst, 1/10) end)? Remove it, it's unneccesary. And also it is better while mod testing, to disable all other mods. Also, new RainCheck:local function RainCheck(inst, data) local threshold = TUNING.WRED.TRANSFORM_MOISTURE_THRESHOLD if not inst.ismonster and (data.new > threshold) then inst.ismonster = true TurnMonster(inst) elseif inst.ismonster and (data.new <= threshold) then inst.ismonster = false inst.AnimState:SetBuild("wred") endend Edited January 28, 2015 by DarkXero Link to comment https://forums.kleientertainment.com/forums/topic/49197-transform-below-wetnessmoisture-threshold/#findComment-606975 Share on other sites More sharing options...
Eir Posted January 28, 2015 Author Share Posted January 28, 2015 (edited) @DarkXeroThanks so much!! Just one more thing, how do I check my wredmonster.zip to see if it has wred ID and how do I fix it? Edited January 28, 2015 by Eir Link to comment https://forums.kleientertainment.com/forums/topic/49197-transform-below-wetnessmoisture-threshold/#findComment-607181 Share on other sites More sharing options...
DarkXero Posted January 28, 2015 Share Posted January 28, 2015 @DarkXeroThanks so much!! Just one more thing, how do I check my wredmonster.zip to see if it has wred ID and how do I fix it?Where did you get wredmonster? Did you copy the wred build and then wrote over it? Link to comment https://forums.kleientertainment.com/forums/topic/49197-transform-below-wetnessmoisture-threshold/#findComment-607239 Share on other sites More sharing options...
Eir Posted January 29, 2015 Author Share Posted January 29, 2015 (edited) Where did you get wredmonster? Did you copy the wred build and then wrote over it? I think I fixed the wredmonster issue. Now I am faced with an error message whenever my character reaches the moisture threshold. Please take a look at my log.log.txt Edited January 29, 2015 by Eir Link to comment https://forums.kleientertainment.com/forums/topic/49197-transform-below-wetnessmoisture-threshold/#findComment-607312 Share on other sites More sharing options...
DarkXero Posted January 30, 2015 Share Posted January 30, 2015 (edited) Eir, I'm glad you fixed it. I was gonna redirect you to: http://forums.kleientertainment.com/topic/48570-help-with-invisible-ghost-on-custom-character/ Move local TurnMonster over local RainCheck in wred.lua. Edited January 30, 2015 by DarkXero Link to comment https://forums.kleientertainment.com/forums/topic/49197-transform-below-wetnessmoisture-threshold/#findComment-607618 Share on other sites More sharing options...
Eir Posted January 30, 2015 Author Share Posted January 30, 2015 (edited) Eir, I'm glad you fixed it. I was gonna redirect you to: http://forums.kleientertainment.com/topic/48570-help-with-invisible-ghost-on-custom-character/ Move local TurnMonster over local RainCheck in wred.lua. Success!!The transformation finally works! Thank you so much, DarkXero. I appreciate you being so patient with me. If I publish my character mod, I will definitely give you credit. Edited January 30, 2015 by Eir Link to comment https://forums.kleientertainment.com/forums/topic/49197-transform-below-wetnessmoisture-threshold/#findComment-607674 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