I’m attempting to allow the user to modify a map, save this and reload the edited map upon reboot of the app. I’m following Dyson’s earlier suggestion of saving the table returned by getMap() as a json string and reloading this instead of the default map file.
The only problem I’m facing is with the new lighting system; it’s been awhile since I last updated MTE - so the new lighting system is completely new to me.
The problem I’m facing is that when loadMap() reached the following code with the edited json file:
[lua]
if not storageToggle then
if map.properties.lightLayerFalloff then
map.properties.lightLayerFalloff = json.decode(map.properties.lightLayerFalloff)
else
map.properties.lightLayerFalloff = {0, 0, 0}
end
if map.properties.lightLevelFalloff then
map.properties.lightLevelFalloff = json.decode(map.properties.lightLevelFalloff)
else
map.properties.lightLevelFalloff = {255, 255, 255}
end
end
[/lua]
The problem seems to be that with the edited json file map.properties.lightLayerFalloff is already a table and so the json.decode() call fails. I have added a type check in each statement to see whether the variable is alreaddy a table that appears to overcome the issue, but just wanted to make sure there wasn’t a “better” way and/if whether this is going to cause any issues down the line.
Like I said it’s been awhile since I stepped through MTE, so any help would be appreciated.