Techmino icon indicating copy to clipboard operation
Techmino copied to clipboard

Ultra's ending shows "1 minute 60 seconds" instead of "2 minutes"

Open Not-A-Normal-Robot opened this issue 3 years ago • 9 comments

image

Steps to reproduce:

  1. Play Ultra
  2. Don't die
  3. Finish Ultra
  4. Look at timer

Not-A-Normal-Robot avatar Nov 13 '21 16:11 Not-A-Normal-Robot

I just realized that it doesn't always end perfectly like that, but it's possible.

Not-A-Normal-Robot avatar Nov 13 '21 16:11 Not-A-Normal-Robot

I think a better way should be to replace that timer with a countdown... Although there is a time bar, I think a countdown would be far more intuitive. Anyway I will talk to MrZ about this

C29H25N3O5 avatar Nov 13 '21 17:11 C29H25N3O5

@Not-A-Normal-Robot @MrZ626 reopen this image

SweetSea-ButImNotSweet avatar Oct 29 '23 10:10 SweetSea-ButImNotSweet

@SweetSea-ButImNotSweet I got 2m 0s like it should do in my test.

  • What's your device and system? (is it system- or machine-dependent?)
  • Does this "1m 60s" thing happen consistently, or just sometimes?

User670 avatar Oct 29 '23 12:10 User670

I'd guess sometimes and it may be dependent on the lag experienced throughout the game.

May be related to the recent time function changes in Zframework.

Not-A-Normal-Robot avatar Oct 29 '23 12:10 Not-A-Normal-Robot

Never mind, I found the cause

https://github.com/26F-Studio/Zframework/blob/d0b485abdbe4490f63ff15fef58f21baddd50f84/stringExtend.lua#L93

convertSecondsToUnits converts second to seconds, minutes, hours, days, and years. When input is, for example 119.999, it outputs 1m 59.999s.

https://github.com/26F-Studio/Zframework/blob/d0b485abdbe4490f63ff15fef58f21baddd50f84/stringExtend.lua#L134

This STRING.time function is responsible for formatting the time. It keeps 2 decimal place for the second, so the 59.999s, rounded to 2 decimal places, is 60.00s.

User670 avatar Oct 29 '23 12:10 User670

I used this to test the behavior of these functions (this is a standalone Lua file, no need to put in Techmino). I changed a few things so that function names and variables are not local, and the second/minute symbols are ASCII (the unicode one doesn't work in my command prompt console).

MINUTE=60
HOUR=3600
DAY=86400
YEAR=31536000 -- 365 days
function convertSecondsToUnits(t) -- convert seconds to {seconds, minutes, hours, days, years}
    local years=math.floor(t/YEAR)
    local remainder=t%YEAR

    local days=math.floor(remainder/DAY)
    remainder=remainder%DAY

    local hours=math.floor(remainder/HOUR)
    remainder=remainder%HOUR

    local minutes=math.floor(remainder/MINUTE)
    local seconds=remainder%MINUTE
    return seconds,minutes,hours,days,years
end

function s_time(t)
    local s,m,h,d,y=convertSecondsToUnits(t)
    if t<MINUTE then
        return string.format("%.3f\"",t) -- example: 12.345″
    elseif t<HOUR then
        return string.format("%d'%05.2f\"",m,s) -- 1′23.45″
    elseif t<DAY then
        return string.format("%d:%.2d'%04.1f\"",h,m,s) -- 12:34′56.7″
    elseif t<YEAR then
        return string.format("%dd %d:%.2d'%.2d\"",d,h,m,s) -- 123d 12:34′56″
    else
        return string.format("%dy %dd %d:%.2d'",y,d,h,m) -- 1y 234d 12:34′
    end
end

-- test: convert seconds to unit
print(convertSecondsToUnits(120))
print(convertSecondsToUnits(119.999))
print(convertSecondsToUnits(119.9999999999999999999))

-- test: string time
print(s_time(120))
print(s_time(119.999))
print(s_time(119.9999999999999999999))

Output:

d:\workspace\!temp>lua time.lua.txt
0       2       0       0       0
59.999  1       0       0       0
0.0     2       0       0       0
2'00.00"
1'60.00"
2'00.00"

User670 avatar Oct 29 '23 12:10 User670

@SweetSea-ButImNotSweet I got 2m 0s like it should do in my test.

  • What's your device and system? (is it system- or machine-dependent?)
  • Does this "1m 60s" thing happen consistently, or just sometimes?

I don't really know if it happens consistently because I just played one in the afternoon Device: Laptop Acer Nitro Gaming AN515-45 (AMD, GTX 1650)

SweetSea-ButImNotSweet avatar Oct 29 '23 12:10 SweetSea-ButImNotSweet

Janky solution that doesn't solve the root cause of the problem: set P.stat.time to 120 upon game end

Not-A-Normal-Robot avatar Oct 29 '23 14:10 Not-A-Normal-Robot