Named elements of a table
Posted: Mon Jul 31, 2017 10:42 am
That is something I just encountered and it made me wonder.
In the manual you can read:
and I decided to replace it with this:
And now I had a lot of errors: "table field was not initialized" and it turned out that my old syntax was causing it:
or from another table:
so I changed these entries to:
and it is working.
Have I misunderstood something here?
In the manual you can read:
Up to now, at the beginning of my script I had following table declaration:You can access named elements of a table also in two ways:
b = a["name"]
b = a.name
Code: Select all
mapSettings = {
["minRmW"] = 3,
["minRmH"] = 3,
["maxRms"] = 5,
["rmChnc"] = 80,
["sparse"] = 50,
["loops"] = 50,
["rndDirTreshold"] = 80
}
Code: Select all
mapSettings = {
minRmW = 3,
minRmH = 3,
maxRms = 5,
rmChnc = 80,
sparse = 50,
loops = 50,
rndDirTreshold = 80
}
And now I had a lot of errors: "table field was not initialized" and it turned out that my old syntax was causing it:
Code: Select all
aLoc=bspSplit(0,0,#W,#H,mapSettings["maxRms"])
Code: Select all
colorReq.shadowOnOff=color["shadowOnOff"]
Code: Select all
mapSettings.maxRms
color.shadowOnOff
Have I misunderstood something here?