Definitely use hero if hero is present in the user code.

This commit is contained in:
Cat Sync 2016-05-13 13:37:36 -04:00
parent 59408c0de2
commit 6e11b0dcda
2 changed files with 2 additions and 2 deletions
app/views/play/level/tome

View file

@ -532,7 +532,7 @@ module.exports = class SpellView extends CocoView
# For now, update autocomplete to use hero instead of self/this, if hero is already used in the source.
# Later, we should make this happen all the time - or better yet update the snippets.
source = @getSource()
if not /(self[\.\:]|this\.|\@)/.test(source)
if /hero/.test(source) or not /(self[\.\:]|this\.|\@)/.test(source)
thisToken =
'python': /self/,
'javascript': /this/,

View file

@ -218,7 +218,7 @@ module.exports = class TomeView extends CocoView
updateSpellPalette: (thang, spell) ->
return unless thang and @spellPaletteView?.thang isnt thang and thang.programmableProperties or thang.apiProperties
useHero = not /(self[\.\:]|this\.|\@)/.test(spell.getSource())
useHero = /hero/.test(spell.getSource()) or not /(self[\.\:]|this\.|\@)/.test(spell.getSource())
@spellPaletteView = @insertSubView new SpellPaletteView thang: thang, supermodel: @supermodel, programmable: spell?.canRead(), language: spell?.language ? @options.session.get('codeLanguage'), session: @options.session, level: @options.level, courseID: @options.courseID, courseInstanceID: @options.courseInstanceID, useHero: useHero
@spellPaletteView.toggleControls {}, spell.view.controlsEnabled if spell?.view # TODO: know when palette should have been disabled but didn't exist