如何在lua中向零舍入

我需要将一个值向零舍入,以便知道它是否比之前大1

我已经尝试了普通舍入,但不像我想要的那样工作。

local ghostwalkspeed = 0

function onTouched(hit)
    if hit.Parent:FindFirstChild("Humanoid") then
        hit.Parent.Humanoid.WalkSpeed = hit.Parent.Humanoid.WalkSpeed + hit.Parent.Humanoid.WalkSpeed/100
            --!!!!!!
        -- 在下面的if语句中,我必须
                -- 将“hit.Parent.Humanoid.WalkSpeed”向零舍入
            --!!!!!!
        if hit.Parent.Humanoid.WalkSpeed > ghostwalkspeed then
            ghostwalkspeed = hit.Parent.Humanoid.WalkSpeed

        end
    end
end

script.Parent.Touched:connect(onTouched)

Ghostwalkspeed为0,walkspeed为1。只有在walkspeed为2时,ghost变量才不应该改变,因此它应该从1.9向1舍入。

点赞
用户2858170
用户2858170
2019-10-22 21:15:00