not able to interact with the brain
herz0g opened this issue · comments
Hi,
I try since hours to set or get some values from the brain without any success. At least also the code snippet on the scripting documentation is not working what makes it really hard to see some success in that attempt ... My code looks like this and the error log tells me the variable is undefinied. My coding skills are really low, so it is not that easy to debug for me, maybe it is just a simple thing missing ...
robot.respond /have a soda/i, (res) ->
sodasHad = robot.brain.get('totalSodas') * 1 or 0
if sodasHad > 4
res.reply "I'm too fizzy.."
else
res.reply 'Sure!'
robot.brain.set 'totalSodas', sodasHad+1
robot.respond /sleep it off/i, (res) ->
robot.brain.set 'totalSodas', 0
msg.reply 'zzzzz'
[Sun Mar 03 2019 01:00:41 GMT+0100 (CET)] ERROR Unable to load /home/bamboo/slack-hubot/scripts/brain: ReferenceError: sodasHad is not defined
Looks like your robot.brain.set
line is outdented all the way. It should be indented to the same depth as the res.reply 'Sure!'
line.
Thanks