Difference between revisions of "TLO:If"

From Lavish Software Wiki
Jump to navigation Jump to search
 
 
(7 intermediate revisions by 4 users not shown)
Line 1: Line 1:
== Synopsis ==
+
== Forms ==
[[DataType:string|string]] '''If['''condition''','''value when true''','''value when false''']'''<br>
+
*[[DataType:string|string]] '''If['''condition''','''value when true''']'''
''- or -''<br>
+
*[[DataType:string|string]] '''If['''condition''','''value when true''','''value when false''']'''
[[DataType:string|string]] '''If['''condition''','''value when true''']'''
+
*Allows conditional usage of different strings. The condition is evaluated as a mathematical formula, after which the result is tested to mean either true (not equal to zero) or false (equal to zero). If the condition evaluates to true, the "value when true" is used. If not, the "value when false" is used, if any.
 
 
== Description ==
 
Allows conditional usage of different strings. The condition is evaluated as a mathematical formula, after which the result is tested to mean either true (not equal to zero) or false (equal to zero). If the condition evaluates to true, the "value when true" is used. If not, the "value when false" is used, if any.
 
  
 
== Examples ==
 
== Examples ==
<tt>echo A coin is flipped, and shows ${If[${Math.Rand[2]==1},heads,tails]}</tt>
+
===Create a hud element using an if statement===
 +
*hud -add test 300,300 ${If[${Me.Dead}||${Me.Ghost},You are currently dead,You are currently alive]}
 +
:This will create a hud element named "Test" at the X,Y of 300,300 that displays "You are currently dead" if ${Me.Dead} OR ${Me.Ghost} evaluates to true, and it will display "You are currently alive" if both are false
  
 
== See Also ==
 
== See Also ==
 
* [[LavishScript:Mathematical Formulae|Mathematical Formulae]]
 
* [[LavishScript:Mathematical Formulae|Mathematical Formulae]]
 +
* [[LavishScript:Top-Level Objects|Top-Level Objects]]
 +
 +
[[Category:LavishScript]]
 +
[[Category:LavishScript Top-Level Objects]]

Latest revision as of 04:32, 1 February 2009

Forms

  • string If[condition,value when true]
  • string If[condition,value when true,value when false]
  • Allows conditional usage of different strings. The condition is evaluated as a mathematical formula, after which the result is tested to mean either true (not equal to zero) or false (equal to zero). If the condition evaluates to true, the "value when true" is used. If not, the "value when false" is used, if any.

Examples

Create a hud element using an if statement

  • hud -add test 300,300 ${If[${Me.Dead}||${Me.Ghost},You are currently dead,You are currently alive]}
This will create a hud element named "Test" at the X,Y of 300,300 that displays "You are currently dead" if ${Me.Dead} OR ${Me.Ghost} evaluates to true, and it will display "You are currently alive" if both are false

See Also