Jump to content

Recommended Posts

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

@rezecib

Yeah, 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 by Eir

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.

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

    end

end

 

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.

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

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.lua

tuning_wred.lua

log.txt

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 by DarkXero

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 by Eir

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 by DarkXero

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 by Eir

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
  • Create New...