Jump to content

怎么改速度?About change speed (every action)


Recommended Posts

I'm trying to make characters act slowly when their hungry-value < 10%

I find that a tag named "hungrybuilder" can change character's speed when they are building,but I want to change the speed when they do everything! How can I do!(Maybee I can see 卵石路's code because characters runs quickly when on it)

This is my code now:

-- modmain.lua
...
AddPlayerPostInit(function(inst)
    if inst.components and inst.components.hunger then
        inst:ListenForEvent("hungerdelta", function (inst, data)
            if data then
                --[[
                    饥饿值小于10%时减慢工作速度
                ]]
                if data.newpercent < 0.1 then
                    inst:AddTag("hungrybuilder")
                elseif data.newpercent > 0.1 and inst:HasTag("hungrybuilder") then
                    inst:RemoveTag("hungrybuilder")
                end
            end
        end)
    end
end)
...

Thank you! My English is not good so I send it again in Chinese

我想把人物在饥饿值低于10%的时候做任何事情的速度都变慢,但是我只找到了能让建造速度面板的tag"hungrybuilder"。

Link to comment
Share on other sites

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
 Share

×
  • Create New...