General functions

All of the functions below are implemented in C#.

prints the text text into the game's lualog.txt. When called from the ingame lua editor, the parameter text is passed to the Lua console window below the ingame lua editor.

function print(text) 

clamp(value, min, max)

This internally calls Mathf.Clamp in C#. It returns a float that is

  • equal to value if value is between min and max
  • equal to min if value is smaller than min
  • equal to max if value is larger than max.

All inputs are floats.

function clamp(value, min, max) 

clamp01(value)

Same as clamp(), but with min equal to 0 and max equal to 1. This internally calls Mathf.Clamp01 in C#.

function clamp01(value) 

lerp(a, b, t)

This internally calls Mathf.Lerp in C#. Returns a float that is interpolated between a and b, depending on t (all floats). This will return

  • a in case t == 0
  • b in case t == 1
  • 0.5*(a+b) in case t == 0.5
  • and so on.
function lerp(a, b, t) 

inverseLerp(a, b, value)

This internally calls Mathf.InverseLerp in C#. It returns the parameter t that would produce the interpolated value within the range a and b (all floats). This will return

  • 0 in case value == a
  • 1 in case value == b
  • 0.5 in case value == 0.5*(a+b)
  • and so on.
function inverseLerp(a, b, value) 

map(a,b, x,y, value)

This will convert a value between a and b so that it is interpolated between x and y. It is comparable to Arduino's map( function), but please note that the argument order is modified to match the order of lerp. The function will return

  • x in case value == a
  • y in case value == b
  • 0.5*(x+y) in case value == 0.5*(a+b)
  • and so on.

All input parameters are floats.

Note that lerp(a, b, t) actually yields the same as calling map(0,1, a,b, t). Also note that inverseLerp(a, b, value) is actually the same as map(a,b, 0,1, value).

function map(a,b, x,y, value) 

mapClamped(a,b, x,y, value)

This is the same as map, except that the return value cannot exceed the range between x and y.

function mapClamped(a,b, x,y, value) 

getTime()

This returns the time in seconds since the start of the game. The return value will be a float.

function getTime() 

getTimeMicros()

This returns the time in microseconds since the start of the game, i.e. it will return 1000000 one second after the start of the game. It can be helpful for (rather) precisely timing actions, such as breaking loops that could cause the game to freeze and continue calculating in the next frame. The return value will be a float.

function getTimeMicros() 

All contents of this page may be used for modding use for Winter Resort Simulator only. Any use exceeding this regulation is not permitted.

Copyright (C) HR Innoways, 2020. All Rights Reserved.