aboutsummaryrefslogtreecommitdiff
path: root/game2.moon
blob: 3d5f1ae4f5306a7eb31776bde67736ac147f8b62 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
#!/usr/bin/env moon
utils = require 'utils'
Game = require 'nomic'
g = Game(require'core')

print("===========================================================================================")


g\run[[

say [..]
    "this is a stupidly long list", "the items go way past the 80 character", "limit that older consoles"
    "had.", "It just keeps going and going"

rule "dumbfunc %a %b %c %d %e":
    say "doop"

dumbfunc..
    "this is a stupidly long set of arguments" "the items go way past the 80 character" "limit that older consoles"
    "had." "It just keeps going and going"

]]
g\run[[
rule "four": return 4
rule "say both %one and %two":
    say %one
    say %two

say both ..
    "a list:"
    and [..]
        1,2,3,(four),(5)

say "done"
]]

g\run[[
rule "do %thing also %also-thing":
    do %thing
    do %also-thing
    return 99
]]
g\run[[
do: say "one liner"
..also: say "another one liner"
]]
g\run[[

say (..)
    do:
        say "hi"
        return 5
        say "bye"

]]
g\run[[
say (do: return "wow")
if 1: say "hi1" ..else: say "bye1"

if 1: say "hi2"
..else: say "bye2"

]]
g\run[[
rule "foo %x":
    if %x:
        say "YES"
        55
    ..else:
        say "NO"
        -99

say (foo 1)
say (foo (false))

]]

g\run[[
say (1 + (-(2 * 3)))
]]

g\run[[
for "x" in ["A","B","C"]:
    say %x
]]
g\run[[
say (for "x" in [1,2,3]:%x + 100)
say (..)
    for "x" in [1,2,3]:
        %x + 200
]]

g\run[[
if (1 == 1):
    say "Simple macros work!"
unless (1 > 2):
    say "This one too!"
]]

g\simplemacro [[smet %varname = %value]],[[
lua ["vars[\"", %varname, "\"] = ", %value]
lua ["vars[\"", %varname, "\"] = 2*vars[\"", %varname, "\"]"]
]]

g\run[[
smet "fnord" = 23
say %fnord
]]

g\run[[

rule "fizz buzz":
    for "i" = 1 to 100:
        if ((%i mod 15) == 0):
            say "fizzbuzz"
        ..else: if ((%i mod 3) == 0):
            say "fizz"
        ..else: if ((%i mod 5) == 0):
            say "buzz"
        ..else:
            say %i

fizz buzz

]]