Difference between revisions of "Set"

No change in size ,  17:47, 10 October 2008
m
imported>Qazaaq
m (update tag)
imported>UDUN
 
Line 43: Line 43:
  set a to 9.0/5  ; will set "a" to 1.800
  set a to 9.0/5  ; will set "a" to 1.800


*When you want to store the correctly rounded result of a division in an integer-variable, you need to make sure, that the calculation uses floating poing (so that the decimal-fraction isn't truncated) and add 0.5:  
*When you want to store the correctly rounded result of a division in an integer-variable, you need to make sure, that the calculation uses floating point (so that the decimal-fraction isn't truncated) and add 0.5:  
  short a
  short a
  set a to 9/5          ; will set "a" to 1
  set a to 9/5          ; will set "a" to 1
Line 61: Line 61:




*You can also use a comparsion as the "value". The variable will then be set either to 1 or 0 depending on whether the condition is true or not.
*You can also use a comparison as the "value". The variable will then be set either to 1 or 0 depending on whether the condition is true or not.


  set goodluck to player.Getav luck > 60
  set goodluck to player.Getav luck > 60
Line 73: Line 73:
  endif
  endif


You can use arithmetic operations on a comparsion value, but when you do so you need to put the comparsion in parentheses:
You can use arithmetic operations on a comparison value, but when you do so you need to put the comparison in parentheses:


  set luckbonus to 50*(player.Getav luck > 60)
  set luckbonus to 50*(player.Getav luck > 60)
Anonymous user