Posted 21 September 2015 - 08:34 AM
I want to convert the following block of code:
into one line, or something more plesent:
but I am confused as how to do this. Here's my attempt:
What am i doing wrong?
if not blockData[x] then blockData[x] = {} end
if not blockData[x][y] then blockData[x][y] = {} end
if not blockData[x][y][z] then blockData[x][y][z] = {} end
blockData[x][y][z]["name"] = data["name"]
blockData[x][y][z]["metadata"] = data["metadata"]
into one line, or something more plesent:
blockData = {
[x]={
[y]={
[z]={
name=data["name"],
metadata=data["metadata"]
}}}}
but I am confused as how to do this. Here's my attempt:
blockData = {
_index = if not [x] then
[x]={}
end
return [x] = x
}
What am i doing wrong?
Edited on 21 September 2015 - 09:35 AM