This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionNext revisionBoth sides next revision | ||
script_syntax [2021/04/02 19:44] – justin | script_syntax [2021/04/02 19:56] – justin | ||
---|---|---|---|
Line 238: | Line 238: | ||
====String/ | ====String/ | ||
- | There are two functions available for converting between a [[string]] and a [[number]]: **str** and **num**. When a variable or property is known to contain a numeric value and you need to concatenate it with a [[string]], you can convert the [[number]] to a [[string]] using the **str** function. Similarly, if you have a [[string]] and you know it contains a valid numeric value, you can convert it to a [[number]] for use in an arithmetic | + | There are two functions available for converting between a [[string]] and a [[number]]: **str** and **num**. When a variable or property is known to contain a numeric value and you need to concatenate it with a [[string]], you can convert the [[number]] to a [[string]] using the **str** function. Similarly, if you have a [[string]] and you know it contains a valid numeric value, you can convert it to a [[number]] for use in arithmetic |
+ | **Examples: | ||
+ | <code bauxite> | ||
+ | $next_num += 1; | ||
+ | $new_tile_id = " | ||
+ | </ | ||
+ | <code bauxite> | ||
+ | $string_with_num = " | ||
+ | $new_value = num($string_with_num) + 20 | ||
+ | </ | ||
~~NOTOC~~ | ~~NOTOC~~ |