• My Pages
  • Comments
  • Add Link
  • Subscribe
  • Subscribe User
  • Edit (GUI)
  • Edit (Text)
  • Rename Page
  • Copy Page
  • Load Page
  • Save Page
  • Delete Page
  • Attachments
  • Check Spelling
  • Diffs
  • Info
  • Revert to this revision
  • XML
  • Render as Docbook
  • Print View
  • Raw Text
  • Delete Cache
  • Like Pages
  • Local Site Map
  • Remove Spam
  • Package Pages
  • Sync Pages
    • Diff for "Math"
    Differences between revisions 16 and 24 (spanning 8 versions)
    Revision 16 as of 2014-02-12 17:43:25
    Size: 7789
    Editor: Inanna
    Comment:
    Revision 24 as of 2015-02-13 20:59:39
    Size: 7225
    Editor: LKD70
    Comment:
    Deletions are marked like this. Additions are marked like this.
    Line 1: Line 1:
    ## page was renamed from Math
    Line 11: Line 10:
    '''Methods'''
    ||<tablewidth="796px" tableheight="123px"#cccccc>'''Method ''' ||<#cccccc>'''Type''' ||<#cccccc>'''Description ''' ||||<style="text-align:center"> ||
    '''Functions'''
    ||<tablewidth="796px" tableheight="123px"#cccccc>'''Function ''' ||<#cccccc>'''Type''' ||<#cccccc>'''Description ''' ||||<style="text-align:center"> ||
    Line 22: Line 21:
    ||[[#FormatMiles|FormatMiles]] ||int ||Converts number to a string, e.g. "2.34 miles". ||
    ||[[#FormatNumber|FormatNumber]] ||int ||Formats number with specified precision, e.g. "2,346". ||
    ||[[#FormatNumber2|FormatNumber2]] ||int ||Formats numbers with 2 decimal places, e.g. "2,345.56". ||
    ||[[#FormatPercent|FormatPercent]] ||int ||Formats number as percentage, e.g. "9.1%". ||
    Line 38: Line 33:
    Line 39: Line 35:
    '''Usage:''' '''Usage:''' abs(number)
    Line 58: Line 54:
    '''Usage:''' '''Usage:''' acos(number.decimal)
    Line 64: Line 60:
     .

    '''Result:'''

     .
     echo acos(0.75)

    '''Result:'''

     (City Name) - 0.7227342478134157
     (City Name) - Script stopped
    Line 71: Line 68:
    '''Usage:''' '''Usage:''' asin(number.decimal)
    Line 77: Line 74:
     .

    '''Result:'''

     .
     echo asin(0.75)

    '''Result:'''

     (City Name) - 0.848062078981481
     (City Name) - Script stopped
    Line 84: Line 83:
    '''Usage:''' '''Usage:''' atan(Number)
    Line 90: Line 89:
     .

    '''Result:'''

     .
     echo atan(7)

    '''Result:'''

     (City Name) - 1.4288992721907328
     (City Name) - Script stopped
    Line 97: Line 97:
    '''Usage:''' '''Usage:''' atan2(!FirstNumber, !SecondNumber)
    Line 103: Line 103:
     .

    '''Result:'''

     .
     echo atan2(7,3)

    '''Result:'''

     (City Name) - 1.1659045405098132
     (City Name) - Script stopped
    Line 110: Line 112:
    '''Usage:''' '''Usage:''' ceil(Number.Decimal)
    Line 120: Line 122:
    5  (City Name) - 5
     (City Name) - Script stopped
    Line 123: Line 127:
    '''Usage:''' '''Usage:''' cos(angle)
    Line 129: Line 133:
     .

    '''Result:'''

     .
     echo cos(7)

    '''Result:'''

     (City Name) - 0.7539022543433046
     (City Name) - Script stopped
    Line 136: Line 142:
    '''Usage:''' '''Usage:''' exp(number)
    Line 142: Line 148:
     .

    '''Result:'''

     .
     echo exp(7)

    '''Result:'''

     (City Name) - 1096.633158428458
     (City Name) - Script stopped
    Line 149: Line 156:
    '''Usage:'''

    Returns the floor of the number or expression specified in the paraenthesis... Floor is the whole number part, without the decimals. Basically means chop the decimal portion of the number off.
    '''Usage:''' floor(Number.decimal)

    Returns the floor of the number or expression specified in the parenthesis... Floor is the whole number part, without the decimals. Basically means chop the decimal portion of the number off.
    Line 159: Line 166:
    1234  (City Name) - 1234
     (City Name) - Script stopped
    Line 162: Line 170:
    '''Usage:''' '''Usage:''' pow(base, exponent)
    Line 168: Line 176:
     .

    '''Result:'''

     .

    = FormatMiles =
    '''Usage:''' !FormatMiles(number)

    Converts number to a string like "2.34 miles".

    '''Example:'''
     .echo !FormatMiles(123)
     .echo !FormatMiles(123.4)

    '''Result:'''
     .12:42:57 123.00 miles
     .12:42:58 123.40 miles

    = FormatNumber =
    '''Usage:''' !FormatNumber(number, optional precision = 0, optional useThousandsSeparator = true)

    Formats number with specified precision. Default has no decimal places, e.g. "2,346"

    '''Example:'''
     .echo !FormatNumber("1234567")
     .echo !FormatNumber("1234567","2")

    '''Result:'''
     .12:23:01 1,234,567
     .12:23:02 1,234,567.00

    = FormatNumber2 =
    '''Usage:''' !FormatNumber2(number, optional precision = 0, optional useThousandsSeparator = true)

    Formats number with 2 decimal places, e.g. "2,345.56".

    '''Example:'''
     .echo !FormatNumber2("1234567")

    '''Result:'''
     .12:40:14 1,234,567.00

    = FormatPercent =
    '''Usage:''' !FormatPercent(number, optional presision = 1)

    Formats number as percentage.

    '''Example:'''
     .echo !FormatPercent("1")
     .echo !FormatPercent("0.25","0")
     .echo !FormatPercent("0.25","2")

    '''Result:'''
     .12:17:57 100.0%
     .12:17:58 25%
     .12:17:59 25.00%
     echo pow(7, 3)

    '''Result:'''

     (City Name) - 343
     (City Name) - Script stopped
    Line 227: Line 185:
    '''Usage:''' '''Usage:''' max(!FirstValue, !SecondValue)
    Line 242: Line 200:
    '''Usage:''' '''Usage:''' min(!FirstValue, !SecondValue)
    Line 256: Line 214:
     .

    = pow =
    '''Usage:'''

    Computes and returns base to the power of pow.

    '''Example:'''

     .

    '''Result:'''

     .

    Line 272: Line 218:
    '''Usage:''' '''Usage:''' random()
    Line 289: Line 235:
    '''Usage:''' '''Usage:''' round(number.decimal,[optional] places)
    Line 316: Line 262:
    '''Usage:''' '''Usage:''' sin(angle)
    Line 322: Line 268:
     .

    '''Result:'''

     .
     echo sin(3)

    '''Result:'''

     (City Name) - 0.1411200080598672
     (City Name) - Script stopped
    Line 329: Line 277:
    '''Usage:''' '''Usage:''' sqrt(number)
    Line 335: Line 283:
     .

    '''Result:'''

     .
     echo sqrt(16)

    '''Result:'''

     (City Name) - 4
     (City Name) - Script stopped
    Line 342: Line 292:
    '''Usage:''' '''Usage:''' tan(angle)
    Line 348: Line 298:
     .

    '''Result:'''

     .
     echo tan(4)

    '''Result:'''

     (City Name) - 1.1578212823495775
    (City Name) - Script stopped

    The following functions can be used to perform arithmetic on objects and variables.

    These should be written in the following formats:

    • variable.method(arguments), example - ...

    • object.method(arguments), example - ...

    Click each method name in the table below for more details of it, with examples.

    Functions

    Function

    Type

    Description

    abs

    int

    Computes and returns an absolute value for the number specified by the parameter val.

    acos

    int

    Computes and returns the arc cosine of the number specified in the parameter val, in radians.

    asin

    int

    Computes and returns the arc sine for the number specified in the parameter val, in radians.

    atan

    int

    Computes and returns the value, in radians, of the angle whose tangent is specified in the parameter val.

    atan2

    int

    Computes and returns the angle of the point y/x in radians, when measured counterclockwise from a circle's x axis (where 0,0 represents the center of the circle).

    ceil

    int

    Returns the ceiling of the specified number or expression.

    cos

    int

    Computes and returns the cosine of the specified angle in radians.

    exp

    int

    Returns the value of the base of the natural logarithm (e), to the power of the exponent specified in the parameter x.

    floor

    int

    Returns the floor of the number or expression specified in the parameter val.

    log

    int

    Returns the natural logarithm of the parameter val.

    max

    int

    Evaluates val1 and val2 (or more values) and returns the largest value.

    min

    int

    Evaluates val1 and val2 (or more values) and returns the smallest value.

    pow

    int

    Computes and returns base to the power of pow.

    random

    int

    Returns a pseudo-random number n, where 0 <= n < 1.

    round

    int

    Rounds the value of the parameter val up or down to the nearest integer and returns the value.

    sin

    int

    Computes and returns the sine of the specified angle in radians.

    sqrt

    int

    Computes and returns the square root of the specified number.

    tan

    int

    Computes and returns the tangent of the specified angle.

    abs

    Usage: abs(number)

    Computes and returns an absolute value for the number specified by the parameter val.

    Example:

    echo abs(-123456)

    echo abs(123456)

    Result:

    123456

    123456

    acos

    Usage: acos(number.decimal)

    Computes and returns the arc cosine of the number specified in the parameter val, in radians.

    Example:

    • echo acos(0.75)

    Result:

    • (City Name) - 0.7227342478134157 (City Name) - Script stopped

    asin

    Usage: asin(number.decimal)

    Computes and returns the arc sine for the number specified in the parameter val, in radians.

    Example:

    • echo asin(0.75)

    Result:

    • (City Name) - 0.848062078981481 (City Name) - Script stopped

    atan

    Usage: atan(Number)

    Computes and returns the value, in radians, of the angle whose tangent is specified in the parameter val.

    Example:

    • echo atan(7)

    Result:

    • (City Name) - 1.4288992721907328 (City Name) - Script stopped

    atan2

    Usage: atan2(FirstNumber, SecondNumber)

    Returns a string comprising the characters represented by the Unicode character codes in the parameters.

    Example:

    • echo atan2(7,3)

    Result:

    • (City Name) - 1.1659045405098132 (City Name) - Script stopped

    ceil

    Usage: ceil(Number.Decimal)

    Returns the ceiling of the specified number or expression. Basically this means return the number rounded up to next whole number

    Example:

    echo ceil(4.1)

    Result:

    • (City Name) - 5 (City Name) - Script stopped

    cos

    Usage: cos(angle)

    Computes and returns the cosine of the specified angle in radians.

    Example:

    • echo cos(7)

    Result:

    • (City Name) - 0.7539022543433046 (City Name) - Script stopped

    exp

    Usage: exp(number)

    Returns the value of the base of the natural logarithm (e), to the power of the exponent specified in the parameter x.

    Example:

    • echo exp(7)

    Result:

    • (City Name) - 1096.633158428458 (City Name) - Script stopped

    floor

    Usage: floor(Number.decimal)

    Returns the floor of the number or expression specified in the parenthesis... Floor is the whole number part, without the decimals. Basically means chop the decimal portion of the number off.

    Example:

    echo floor(1234.56)

    Result:

    • (City Name) - 1234 (City Name) - Script stopped

    pow

    Usage: pow(base, exponent)

    Computes and returns base to the power of pow.

    Example:

    • echo pow(7, 3)

    Result:

    • (City Name) - 343 (City Name) - Script stopped

    max

    Usage: max(FirstValue, SecondValue)

    Evaluates val1 and val2 (or more values) and returns the largest value.

    Example:

    echo max( city.troop.scouter, 100k )

    Result:

    If city.troop.scouter (the current number of scouts in the city) < 100k, then max( city.troop.scouter, 100k ) will return the number of scouts in city. If city.troop.scouter >= 100k then it will return 100000

    min

    Usage: min(FirstValue, SecondValue)

    Evaluates val1 and val2 (or more values) and returns the smallest value.

    Example:

    echo min(city.resource.food.amount,99999999)

    Result:

    this will return whichever is smaller, 99,999,999 or the current amount of food in the city

    random

    Usage: random()

    Returns a pseudo-random number n, where 0 <= n < 1.

    Example:

    echo round(random()*10)

    Result:

    a random number between 0 and 9

    round

    Usage: round(number.decimal,[optional] places)

    Rounds the value of the parameter val up or down to the nearest integer and returns the value. Optional argument to specify precision (or number of decimal places).

    Example:

    echo round(6.66666666666666666666)

    echo round(6.66666666666666666666,1)

    echo round(6.66666666666666666666,2)

    echo round(6.66666666666666666666,3)

    Result:

    7

    6.7

    6.67

    6.667

    sin

    Usage: sin(angle)

    Computes and returns the sine of the specified angle in radians.

    Example:

    • echo sin(3)

    Result:

    • (City Name) - 0.1411200080598672 (City Name) - Script stopped

    sqrt

    Usage: sqrt(number)

    Computes and returns the square root of the specified number.

    Example:

    • echo sqrt(16)

    Result:

    • (City Name) - 4 (City Name) - Script stopped

    tan

    Usage: tan(angle)

    Computes and returns the tangent of the specified angle.

    Example:

    • echo tan(4)

    Result:

    • (City Name) - 1.1578212823495775

    (City Name) - Script stopped



    CategoryFunctions

    Math (last edited 2015-02-13 20:59:39 by LKD70)