diff --git a/app/lib/world/world.coffee b/app/lib/world/world.coffee index 6d55c211b..a6ba95418 100644 --- a/app/lib/world/world.coffee +++ b/app/lib/world/world.coffee @@ -245,11 +245,17 @@ module.exports = class World addScripts: (scripts...) -> @scripts = (@scripts ? []).concat scripts + addTrackedProperties: (props...) -> + @trackedProperties = (@trackedProperties ? []).concat props + serialize: -> # Code hotspot; optimize it if @frames.length < @totalFrames then worldShouldBeOverBeforeSerialization [transferableObjects, nontransferableObjects] = [0, 0] - o = {name: @name, totalFrames: @totalFrames, maxTotalFrames: @maxTotalFrames, frameRate: @frameRate, dt: @dt, victory: @victory, userCodeMap: {}, showCoordinates: @showCoordinates, showGrid: @showGrid, showPaths: @showPaths, indieSprites: @indieSprites} + o = {name: @name, totalFrames: @totalFrames, maxTotalFrames: @maxTotalFrames, frameRate: @frameRate, dt: @dt, victory: @victory, userCodeMap: {}} + + o[prop] = @[prop] for prop in @trackedProperties or [] + for thangID, methods of @userCodeMap serializedMethods = o.userCodeMap[thangID] = {} for methodName, method of methods