User Tools

Site Tools


Sidebar



Minetest Forum
Content Database
Git Repository
Bug Tracker
Website

dev:core:funref:ms_to_kmh

advtrains.ms_to_kmh

Converts a speed unit in meters per seconds to kilometers per hour.

Note: this page has been written for Advtrains 2.0.1 TSS and Minetest 5.1.0. Examples and practices described in this page don't take advantage of improvements introduced in later releases.

Syntax

advtrains.ms_to_kmh(speed)

Parameters

  • speed (number): a speed unit in meters per second

Returns

The corresponding speed unit in kilometers per hour.

Calculation

        1/1000 km   3600
1 m/s = --------- = ---- km/h = 3.6 km/h
        1/3600 h    1000

Examples

advtrains.ms_to_kmh(1)  -- 3.6 km/h
advtrains.ms_to_kmh(3)  -- 10.8 km/h
advtrains.ms_to_kmh(20) -- 72 km/h
advtrains.ms_to_kmh(25) -- 90 km/h

In source code

advtrains/helpers.lua, lines 235 to 237:

ms_to_kmh.lua
function advtrains.ms_to_kmh(speed)
    return speed * 3.6
end
dev/core/funref/ms_to_kmh.txt · Last modified: 2020/01/22 10:53 by admin