Player heading as a route number

  • Hoping it can be useful for somebody, below there is a component function (so, not a complete script) which returns the player heading as a route number, as used in aircraft / ship navigation (N = 360, E= 090, S = 180, W = 270 and other in between). There is plenty of script examples into which to plug this function and have an on-screen output.


    1) The function accepts as parameter an event, of the same type of the events passed to many on<Event> callback functions.

    2) It is customary to represent routes as 3-digit number with 0 padding (as in 090 for E); the function just returns an integer, to be formatted at wish.

    3) For N only 360 is normally used, never 000. The function returns 360 if coming from W and 0 if coming from E; adjust if this disturbs you.

    4) I exceeded with comments to clarify the steps; reduce them, if you prefer.

    5) Even if the scripting framework is going to change to Java, for a purely computational function like this, conversion should be straightforward.

Participate now!

Don’t have an account yet? Create a new account now and be part of our community!