nodeMCU Lua中的node.input()是否应该处理字符串?

这段代码是否执行并将“bar”赋值给变量baz?

foo = "bar"
baz = "bazza"
cmd = "baz = foo"
node.input(cmd)
print("this is foo "..foo)
print("this is baz "..baz)

预期输出应为:

this is foo bar
this is baz bar

但事实并非如此,我是否漏掉了什么?

点赞
用户1721055
用户1721055

Ahh hah moment, 在查看源代码后,看来是使用定时器执行命令,所以稍微等待一下后,我得到了预期的结果。这很有效。

function launch()
  foo = "bar"
  baz = "bazza"
  cmd = "baz = foo"
  node.input(cmd)
  print("this is foo "..foo)
  print("this is baz "..baz)

  tmr.alarm( 1 , 50 , 0 , somethingElse )

end

function somethingElse()
  print("this is foo "..foo)
  print("this is baz "..baz)
end

tmr.alarm( 0 , 15000 , 0 , launch )
2015-12-01 23:04:57