This shows you the differences between two versions of the page.
harlowe:it [2017/06/19 02:55] l |
harlowe:it [2017/10/09 20:39] |
||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====It keyword==== | ||
- | This keyword is a shorthand for the closest leftmost value in an expression. It lets you write | ||
- | ''%%(if: $candles < 2 and it > 5)%%'' instead of ''%%(if: $candles < 2 and $candles > 5)%%'', or ''%%(set: $candles to it + 3)%%'' | ||
- | instead of ''%%(set: $candles to $candles + 3)%%''. (You can't, however, use it in a [[harlowe:put|(put:)]] or [[harlowe:move|(move:)]] macro: | ||
- | ''%%(put:$red + $blue into it)%%'' is invalid.) | ||
- | |||
- | Since ''%%it%%'' uses the closest leftmost value, ''%%(print: $red > 2 and it < 4 and $blue > 2 and it < 4)%%'' is the same as | ||
- | ''%%(print: $red > 2 and $red < 4 and $blue > 2 and $blue < 4)%%''. | ||
- | |||
- | ''%%it%%'' is case-insensitive: ''%%IT%%'', ''%%iT%%'' and ''%%It%%'' are all acceptable as well. | ||
- | |||
- | In some situations, the ''%%it%%'' keyword will be //inserted automatically// by Harlowe when the story runs. If you write an | ||
- | incomplete comparison expression where the left-hand side is missing, like ''%%(print: $red > 2 and < 4)%%'', | ||
- | then, when running, the ''%%it%%'' keyword will automatically be inserted into the absent spot - producing, in this case, | ||
- | ''%%(print: $red > 2 and it < 4)%%''. Note that in situations where the ''%%it%%'' keyword would not have an obvious value, such as | ||
- | ''%%(print: < 4)%%'', an error will result nonetheless. | ||
- | |||
- | If the ''%%it%%'' keyword equals a [[harlowe:datamap|datamap]], [[harlowe:string|string]], [[harlowe:Array|array]], or other "collection" data type, then you can access data values | ||
- | using the ''%%its%%'' variant - ''%%(print: $red is 'egg' and its length is 3)%%'' or ''%%(set:$red to its 1st)%%''. Much like the ''%%'s%%'' | ||
- | operator, you can use computed values with ''%%its%%'' - ''%%(if: $red's length is 3 and its $position is $value)%%'' will work as | ||
- | expected. |