diff --git a/app/views/editor/level/scripts/ScriptsTabView.coffee b/app/views/editor/level/scripts/ScriptsTabView.coffee index 0c08b3a58..bc1558f46 100644 --- a/app/views/editor/level/scripts/ScriptsTabView.coffee +++ b/app/views/editor/level/scripts/ScriptsTabView.coffee @@ -39,6 +39,13 @@ module.exports = class ScriptsTabView extends CocoView onScriptsChanged: (e) => @level.set 'scripts', @scriptsTreema.data + lastAction = @scriptsTreema.trackedActions[@scriptsTreema.trackedActions.length - 1] + + if lastAction.action is 'insert' and lastAction.parentPath is '/' + newScript = @scriptsTreema.get lastAction.path + if newScript.id is undefined + @scriptsTreema.set lastAction.path+'/id', 'Script-' + @scriptsTreema.data.length + @scriptTreema.refreshDisplay() onScriptSelected: (e, selected) => selected = if selected.length > 1 then selected[0].getLastSelectedTreema() else selected[0]