Fix for streaming new serialized Aethers into worlds where their Thangs hadn't existed before.

This commit is contained in:
Nick Winter 2014-10-09 09:53:57 -07:00
parent b6f37694e1
commit 45471b8030
2 changed files with 8 additions and 2 deletions
app
lib/world
views/play/level/tome

View file

@ -448,6 +448,8 @@ module.exports = class World
for thangID, methods of o.userCodeMap
for methodName, serializedAether of methods
for aetherStateKey in ['flow', 'metrics', 'style', 'problems']
w.userCodeMap[thangID] ?= {}
w.userCodeMap[thangID][methodName] ?= {}
w.userCodeMap[thangID][methodName][aetherStateKey] = serializedAether[aetherStateKey]
else
w = new World o.userCodeMap, classMap

View file

@ -107,10 +107,14 @@ module.exports = class DocFormatter
v = @options.thang[@doc.name]
else
v = window[@doc.owner][@doc.name] # grab Math or Vector
if @doc.type is 'number' and not isNaN v
if @doc.type is 'number' and not _.isNaN v
if v == Math.round v
return v
return v?.toFixed(2) ? 'null'
if _.isNumber v
return v.toFixed 2
unless v
return 'null'
return '' + v
if _.isString v
return "\"#{v}\""
if v?.id