-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathparseFile.output.lua
38 lines (29 loc) · 1.17 KB
/
parseFile.output.lua
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
--[[============================================================
--=
--= LuaPreprocess example: Pre-parse a data file.
--=
--= Here we convert a JSON data string to a more appropriate
--= data format in the metaprogram. The final program will not
--= contain anything related to JSON - just a nice Lua table
--= literal with all data.
--=
--============================================================]]
-- Metaprogram.
--==============================================================
-- The program.
--==============================================================
local characters = {{actions={{slot="left",title="Slash"},{slot="right",title="Block"}},id=1,name="Warrior",type="melee"},{actions={{slot="left",title="Fireball"},{slot="right",title="Illuminate"},{slot="familiar",title="Swoop"}},id=2,name="Spell Caster",type="magic"}}
function printAvailableCharacters()
print("Available characters:")
for i, character in ipairs(characters) do
print(string.format(
"%d. %s (type: %s, actions: x%d)",
i,
character.name,
character.type,
#character.actions
))
end
end
printAvailableCharacters()
--==============================================================