The performance difference between making a ScriptComponent embedded or external is totally negligible. The only potentially significant difference is that embedded ScriptComponents save their entire source code in the savegame whereas external ones save the path to the file, but this would only be significant in the case of an extremely large script, like hundreds of thousands of lines of code large.
Changing a ScriptComponent from embedded to external will not change the number of constants in your dungeon.lua. You just replace one constant (the source code string) with another constant (the file path string).
I suppose if you make ALL your scripts external or ALL your scripts embedded, then you avoid having the "setSource" or "loadFile" constant respectively, saving a whopping one (1) constant from your 65,536 slots...
So, for the fourth time: My recommendation for getting around the constant limit is to pick out groups of decorative objects that you're unlikely to change, and cut and paste their spawn() calls from your dungeon.lua to an external script file, then have a ScriptComponent load that file. You'll need to add the level to the spawn() calls though, and will want to get rid of editor-generated IDs like "forest_oak_1" (otherwise the next time you place a forest_oak in the editor it will collide with the id in the script).
Or you could start the script with a replacement for the spawn() function. For example:
Code: Select all
-- add level and strip id
local currentLevel = 1
local spawn = function(name,x,y,facing,elevation,id)
spawn(name,currentLevel,x,y,facing,elevation)
end
-- code directly pasted from dungeon.lua level 1 with no changes
spawn("forest_border_rocks_01",6,13,1,0,"forest_border_rocks_01_126")
spawn("forest_border_rocks_01",6,14,1,0,"forest_border_rocks_01_127")
spawn("forest_border_rocks_01",6,15,1,0,"forest_border_rocks_01_128")
spawn("forest_border_rocks_01",7,16,0,0,"forest_border_rocks_01_129")
spawn("forest_border_rocks_01",7,16,1,0,"forest_border_rocks_01_130")
spawn("forest_border_rocks_01",8,17,0,0,"forest_border_rocks_01_131")
spawn("forest_border_rocks_01",8,17,1,0,"forest_border_rocks_01_132")
spawn("forest_border_rocks_01",8,18,1,0,"forest_border_rocks_01_133")
spawn("forest_border_rocks_01",8,19,1,0,"forest_border_rocks_01_134")
spawn("forest_border_rocks_01",8,20,1,0,"forest_border_rocks_01_135")
spawn("forest_border_rocks_01",8,21,1,0,"forest_border_rocks_01_136")
spawn("forest_border_rocks_01",6,9,1,0,"forest_border_rocks_01_137")
spawn("forest_border_rocks_01",6,8,1,0,"forest_border_rocks_01_138")
spawn("forest_border_rocks_01",6,8,0,0,"forest_border_rocks_01_139")
spawn("forest_border_rocks_01",5,7,1,0,"forest_border_rocks_01_140")
spawn("forest_border_rocks_01",5,6,1,0,"forest_border_rocks_01_141")
spawn("forest_border_rocks_01",5,7,3,0,"forest_border_rocks_01_142")
spawn("forest_border_rocks_01",5,6,3,0,"forest_border_rocks_01_143")
spawn("forest_border_rocks_01",5,5,3,0,"forest_border_rocks_01_144")
spawn("forest_border_rocks_01",5,5,0,0,"forest_border_rocks_01_145")
spawn("forest_border_rocks_01",6,4,3,0,"forest_border_rocks_01_146")
spawn("forest_border_rocks_01",5,3,2,0,"forest_border_rocks_01_147")
-- set up for next level
currentLevel = 2
-- more code pasted directly from dungeon.lua level 2 with no changes
spawn("temple_pillar",4,18,3,0,"temple_pillar_81")
spawn("temple_pillar",5,18,3,0,"temple_pillar_82")
spawn("temple_pillar",6,18,3,0,"temple_pillar_83")
spawn("temple_pillar",9,18,0,0,"temple_pillar_86")
spawn("temple_pillar",10,19,2,0,"temple_pillar_88")
spawn("temple_pillar",10,21,3,0,"temple_pillar_90")
spawn("temple_pillar",10,22,0,0,"temple_pillar_91")
spawn("temple_pillar",10,23,2,0,"temple_pillar_92")
spawn("temple_pillar",10,24,1,0,"temple_pillar_93")
spawn("temple_pillar",9,25,3,0,"temple_pillar_95")
spawn("temple_pillar",8,25,2,0,"temple_pillar_96")
spawn("temple_pillar",5,25,0,0,"temple_pillar_99")
spawn("temple_pillar",4,25,2,0,"temple_pillar_100")
spawn("temple_pillar",3,24,1,0,"temple_pillar_102")
spawn("temple_pillar",3,21,1,0,"temple_pillar_105")
spawn("temple_pillar",3,20,2,0,"temple_pillar_106")
spawn("temple_pillar",3,19,0,0,"temple_pillar_107")
Tile/height/reflection/noise maps are stored very efficiently, this really isn't a problem. In fact splitting a 64x64 level into four 32x32 levels will use slightly
space in the dungeon.lua and in memory (but will obviously greatly improve framerate in the actual game!).