Template repo for tiny cross-platform apps that can be modified on phone, tablet or computer.
1{
2 {type='rows', default={font={size=21}, line_height=35},
3 {type='text', font={size=28}, line_height=50,
4 {'Lua@{Lua} > expressions',
5 attrs={
6 Lua={target='--lua'},
7 }},
8 },
9 {type='filler', height=15},
10 {type='text',
11 {'Anywhere in a statement you might use (not define) a variable, you can use an em@{expression} in its place. Some examples:',
12 attrs={
13 em={font={italic=true}}}}},
14 {type='text', '5', font={size=24}},
15 {type='text', ' All values (numbers, strings, tables, etc.) are types.'},
16 {type='filler', height=10},
17 {type='text', '5+3', font={size=24}},
18 {type='text', ' You can add (+), subtract (-), multiply (*), divide (/), compute the remainder (%) of two numbers.'},
19 {type='filler', height=10},
20 {type='text', '4+3*2', font={size=24}},
21 {type='text', ' Expressions can contain other expressions, and they follow the precedence rules you learned in school.'},
22 {type='text', ' Multiplication, division and remainder happen before addition and subtraction.'},
23 {type='filler', height=10},
24 {type='text', '(4+3) * 2'},
25 {type='text', ' To ensure one expression is calculated before another, use parentheses ()'},
26 {type='filler', height=10},
27 {type='text', 'x == y'},
28 {type='text', " You can compare two expressions to determine if they're equal (==), not equal (~=), greater (>), lesser (<), greater or equal (>=), lesser or equal (<=)."},
29 {type='text', " These expressions are handy in the conditions of 'if' statements and loops."},
30 {type='filler', height=10},
31 {type='text', 'x == 3 and y > 4', font={size=24}},
32 {type='text',
33 {' Comparisons return em@{booleans} true or false, which can be combined using and/or.',
34 attrs={
35 em={font={italic=true}}}}},
36 {type='filler', height=10},
37 {type='text', 'not x == 3', font={size=24}},
38 {type='text', ' Turn a boolean into its opposite.'},
39 {type='filler', height=10},
40 {type='text', 'nil or 3', font={size=24}},
41 {type='text', ' All non-boolean values act like true in and/or except for nil.'},
42 {type='filler', height=10},
43 {type='text', '"hello ".."world"', font={size=24}},
44 {type='text', ' String values can be combined using ..'},
45 {type='filler', height=10},
46 {type='text', 'add(2, 3)', font={size=24}},
47 {type='text', ' Function calls can act as expressions as well as statements.'},
48 }
49}