MillhioreBT / forgottenserver-downgrade

TFS Downgrade 1.5+ is an engine based on nekiro downgrade but highly updated with current tfs code, it also has the lua modules divided and uses lua5.4
GNU General Public License v2.0
19 stars 18 forks source link

Exaust Problem #19

Closed IsacViana closed 11 months ago

IsacViana commented 11 months ago

I'm having problems with Exhaustor in Scripts I want to set time to use x item or use x command and I can't because the base doesn't pull the os.time or something similar.

image

When I put 1 it works fine, but when I put 0.x or 1.x it doesn't work.

MillhioreBT commented 11 months ago

In Lua 5.4, integer numbers are differentiated from float numbers, so if you don't round the number before passing it to the storage method then you will get a warning.

IsacViana commented 11 months ago

Isn't there a way to do 0.8s, 1.6s, and so on? @MillhioreBT

MillhioreBT commented 11 months ago

Isn't there a way to do 0.8s, 1.6s, and so on? @MillhioreBT

function Player.setExhaustion(self, key, milliseconds)
    return self:setStorageValue(key, os.mtime() + milliseconds)
end

function Player.getExhaustion(self, key)
    local milliseconds = self:getStorageValue(key)
    if not milliseconds then return 0 end
    return math.max(0, os.mtime() - milliseconds)
end

function Player.hasExhaustion(self, key) return self:getExhaustion(key) > 0 end

you must use milliseconds directly.