local JSON = require"json"
require "tprint"
content = [=[
[
{ "name": "Vision", "rank": "Adept" },
{ "name": "Avoidance", "rank": "Capable" },
{ "name": "Tattoos", "rank": "Inept" },
{ "name": "Survival", "rank": "Transcendent" },
{ "name": "Weaponry", "rank": "Adept" },
{ "name": "Riding", "rank": "Inept" },
{ "name": "Venom", "rank": "Transcendent" },
{ "name": "Hypnosis", "rank": "Mythical" },
{ "name": "Subterfuge", "rank": "Transcendent" },
{ "name": "Constitution", "rank": "Inept" },
{ "name": "Thermology", "rank": "Inept" },
{ "name": "Frost", "rank": "Inept" },
{ "name": "Antidotes", "rank": "Inept" },
{ "name": "Fitness", "rank": "Apprentice" },
{ "name": "Galvanism", "rank": "Inept" },
{ "name": "Philosophy", "rank": "Inept" },
{ "name": "InkMilling", "rank": "Inept" },
{ "name": "Gathering", "rank": "Inept" }
]
]=]
local t = {}
system["char"] = "Setru"
t = (JSON.decode("[" .. content .. "]")[1])
for i = 1, #t in ipairs (t) do
system[system.char] = {
skills = {
[t[i].name] = {
rank = t[i].rank,
abilities = {
},
},
},
}
end
tprint (system[system.char].skills)
end
I keep getting a compile error
Compile error
World: Achaea
Immediate execution
[string "Immediate"]:11: 'do' expected near 'in'
I'm trying to end up with this..
system["Setru"].skills = {
Vision = {
rank = "Adept"
},
Avoidance = {
rank = "Capable"
},
Tattoos = {
rank = "Inept"
},
Survival = {
rank = "Transcendent"
},
Weaponry = {
rank = "Adept"
},
Riding = {
rank = "Inept"
},
Venom = {
rank = "Transcendent"
},
Hypnosis = {
rank = "Mythical"
},
Subterfuge = {
rank = "Transcendent"
},
Constitution = {
rank = "Inept"
},
Thermology = {
rank = "Inept"
},
Frost = {
rank = "Inept"
},
Antidotes = {
rank = "Inept"
},
Fitness = {
rank = "Apprentice"
},
Galvanism = {
rank = "Inept"
},
Philosophy = {
rank = "Inept"
},
InkMilling = {
rank = "Inept"
},
Gathering = {
rank = "Inept"
}
}
EDIT: Made the "content" string easier to read and entered a missing JSON function. Used the MUSHclient forum codes converter on this post. :P |