-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgamescript.awk
More file actions
28 lines (22 loc) · 814 Bytes
/
gamescript.awk
File metadata and controls
28 lines (22 loc) · 814 Bytes
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
# Game scripting
function run_script(script, script_line, groups) {
split(script,a,"\n")
for (i in a) {
script_line = a[i]
# ADD_<TYPE> <name> <x>,<y>
if (match(script_line, /^ADD_([A-Z]+) ([a-zA-Z]+) ([0-9]),([0-9])/, groups)) {
if (groups[1] == "ENTITY") {
add_entity(groups[2], groups[3], groups[4])
} else if (groups[1] == "TILE") {
add_tile(groups[2], groups[3], groups[4])
} else if (groups[1] == "ITEM") {
add_item(groups[2], groups[3], groups[4])
}
}
# SET_<ATTRIBUTE> <value>
else if (match(script_line, /^SET_([A-Z]+) (.+)/, groups)) {
entity_nr = length(ENTITIES)
ENTITIES[entity_nr][tolower(groups[1])] = groups[2]
}
}
}