Simhub – The ultimate cheat sheet

Simhub – The ultimate cheat sheet (WIP)

SImhub ist derzeit wohl die mit Abstand beliebteste Zusatzsoftware in der Simracing-Welt. Nirgendwo sonst lassen sich so viele Einstellungen anpassen und selbst große Simracing-Hersteller unterstützen die Software für Lenkräder, Dashboards und Co. Grund genug, die wichtigsten Funktionen und Codeschnipsel zusammenzutragen. Der Artikel wird laufend aktualisiert, Anregungen aus der Community per Kommentar oder Mail sind herzlich willkommen.

Ncalc – Functions (Simhub)

  • blink(blinkername, blinkdelay, currentstatus) - Returns alternatively true/false every blinkdelay (in milliseconds) if currentstatus is true, else always returns false. blinkername is used to keep function in sync beetween calls.
  • changed(delay, x) – Returns true for a specified delay when x has changed
  • isincreasing(delay, x) – Returns true after a value increase, delay is configured in milliseconds, else always returns false.
  • isdecreasing(delay, value) – Returns true after a value decrease, delay is configured in milliseconds, else always returns false.
  • progress(startvalue, endvalue, currentvalue, [steps]) – Returns a value from 0 to 100, the steps parameter allows to create steps
  • replace(value, search text, replace text)
  • secondstotimespan(seconds) – Returns a time representing the seconds
  • timespantoseconds(timespan) – Returns the number of seconds representing the time (Since 5.1.0Beta4)

For examples, see https://github.com/SHWotever/SimHub/wiki/NCalc-scripting

Ncalc – Functions

NameDescriptionUsageResult
AbsReturns the absolute value of a specified number.Abs(-1)1M
AcosReturns the angle whose cosine is the specified number.Acos(1)0d
AsinReturns the angle whose sine is the specified number.Asin(0)0d
AtanReturns the angle whose tangent is the specified number.Atan(0)0d
CeilingReturns the smallest integer greater than or equal to the specified number.Ceiling(1.5)2d
CosReturns the cosine of the specified angle.Cos(0)1d
ExpReturns e raised to the specified power.Exp(0)1d
FloorReturns the largest integer less than or equal to the specified number.Floor(1.5)1d
IEEERemainderReturns the remainder resulting from the division of a specified number by another specified number.IEEERemainder(3, 2)-1d
LogReturns the logarithm of a specified number.Log(1, 10)0d
Log10Returns the base 10 logarithm of a specified number.Log10(1)0d
MaxReturns the larger of two specified numbers.Max(1, 2)2
MinReturns the smaller of two numbers.Min(1, 2)1
PowReturns a specified number raised to the specified power.Pow(3, 2)9d
RoundRounds a value to the nearest integer or specified number of decimal places. The mid number behaviour can be changed by using EvaluateOption.RoundAwayFromZero during construction of the Expression object.Round(3.222, 2)3.22d
SignReturns a value indicating the sign of a number.Sign(-10)-1
SinReturns the sine of the specified angle.Sin(0)0d
SqrtReturns the square root of a specified number.Sqrt(4)2d
TanReturns the tangent of the specified angle.Tan(0)0d
TruncateCalculates the integral part of a number.Truncate(1.7)1
NameDescriptionUsageResult
inReturns whether an element is in a set of values.in(1 + 1, 1, 2, 3)true
ifReturns a value based on a condition.if(3 % 2 = 1, ‚value is true‘, ‚value is false‘)‚value is true‘

Ncalc – Operators

  • Logical
    • or, ||
    • and, &&
  • Relational
    • =, ==, !=, <>
    • <, <=, >, >=
  • Additive
    • +, –
  • Multiplicative
    • *, /, %
  • Bitwise
    • & (bitwise and), | (bitwise or), ^(bitwise xor), << (left shift), >>(right shift)
  • Unary
    • !, not, -, ~ (bitwise not)
  • Primary
    • (, )
    • values

Examples

  • Fade in / out inertia(if (condition, 100, 0), 100) Opacity is 100% if the condition is true, fading in/out in one second

Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert