The International Simutrans Forum

Development => Patches & Projects => Incorporated Patches and Solved Bug Reports => Topic started by: Yona-TYT on May 16, 2021, 04:47:20 PM

Title: Inconsistency when getting values from "difftick_to_string"
Post by: Yona-TYT on May 16, 2021, 04:47:20 PM
 The displayed values are incorrect, for example if I enter a value of 30 (0: 30h) the value shown in "difftick_to_string" is (0: 01h), I can fix this from the script simply by multiplying the value "entrie.wait "by 16.
Title: Re: Inconsistency when getting values from "difftick_to_string"
Post by: Yona-TYT on May 16, 2021, 05:42:45 PM
Upgrade.
For pak128 I multiply "entrie.wait" by 8.
For pak64 I multiply "entrie.wait" by 16.

I make this setting so that "difftick_to_string" shows the correct value.


function is_schedule_allowed(pl, schedule)
{
    local nr = schedule.entries.len()
    if(nr>0){
        local entrie = schedule.entries[0]
        if(entrie.wait){
            local halt   = entrie.get_halt( player_x(pl) )
            if (halt){
                return "Wait Time: "+entrie.wait+" :: Difftick tostring: "+difftick_to_string(entrie.wait*8)+""
            }
        }
    }
    return null
}
Title: Re: Inconsistency when getting values from "difftick_to_string"
Post by: Dwachs on May 17, 2021, 06:09:27 AM
I see, can be fixed.

In the meantime, prissi created another behavior for absolute departure time. Please do not ask to make this available for scripting as long as this feature is not finalized.
Title: Re: Inconsistency when getting values from "difftick_to_string"
Post by: prissi on May 17, 2021, 06:40:50 AM
The schedule waiting time is 65535 ticks per month. However, difftick_to_string() needs them in bits_per_month. Hence you need to shift it left by bit_shifts_per_month-16
Title: Re: Inconsistency when getting values from "difftick_to_string"
Post by: Dwachs on May 19, 2021, 06:17:17 PM
Please try r9790. I added a new method to schedule_entry_x: waiting_time_to_string. To call it use

local entry = schedule.entries[0]
print(entry.waiting_time_to_string)
Title: Re: Inconsistency when getting values from "difftick_to_string"
Post by: Yona-TYT on June 02, 2021, 04:33:43 PM
Quote from: Dwachs on May 19, 2021, 06:17:17 PMPlease try r9790. I added a new method to schedule_entry_x: waiting_time_to_string. To call it use local entry = schedule.entries[0] print(entry.waiting_time_to_string)
Thank you very much, this works great.  8)