News:

Simutrans Wiki Manual
The official on-line manual for Simutrans. Read and contribute.

Inconsistency when getting values from "difftick_to_string"

Started by Yona-TYT, May 16, 2021, 04:47:20 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Yona-TYT

 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.

Yona-TYT

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
}

Dwachs

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.
Parsley, sage, rosemary, and maggikraut.

prissi

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

Dwachs

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)
Parsley, sage, rosemary, and maggikraut.

Yona-TYT

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)