Zyllos / tts_ftc_base_lua_scripts

FTC Map Base Lua Scripts
3 stars 2 forks source link

Terrain Extractor is Broken #8

Closed Zyllos closed 3 years ago

Zyllos commented 3 years ago

When performing a Map Making load and attempting to extract the terrain, the following error is received:

Error in Script (Extract terrain - 70b9f6): chunk_3:(265,38-40): attempt to index a nil value.

Zyllos commented 3 years ago

Upon reviewing the deleteTable() function in ExtractTerrain object, the function assumed all objects would exist. Either between changes, guids changing, or something else, some of those guids that are iterated in that list, returned nil on the getObjectFromGUID() call.

Added a simple check for the object for nil before attempting to call obj.destroy().

When testing this code, I receive no more errors in scripts and it looks like all objects within the table have been deleted other than the map center (as per expected). Based on this, I believe some of these objects have been removed or deleted earlier in code when executing the "Extract Terrain" button.

Zyllos commented 3 years ago

I tested this change by selecting "Select Map for Map Making" then added any objects onto the terrain in the middle. Then, I pressed the "Extract Terrain" button and clicked "Yes". After finishing this process, I checked the list of object scripts under Modding > Scripting. The only objects shown are the newly created objects I placed, map url object (contains the FTC/BCB info for additive loading, and map url debug, which contains the flag BCBtype = "terrain".

Reviewing all of these executions, this seems like the correct outcome desired. As such, I believe this fix resolves the issue.

Zyllos commented 3 years ago

Bug Fix Test Steps: