farmbot开发入门教程-lua Advanced
说明:
- 介绍FarmBot OS 中的高级 Lua 函数列表
介绍:
序列(id,变量?)
- 使用可选变量执行子序列。
-- Execute a subsequence without variables
subsequence = variable("Subsequence")
sequence(subsequence.id)
-- Execute a subsequence that has a number variable named "time"
subsequence = variable("Subsequence")
sequence(subsequence.id, {
time = {
kind = "numeric",
args = { number = 1500 } }
})
-- Execute a subsequence that has a text variable named "time in ms"
subsequence = variable("Subsequence")
variable = {}
variable["time in ms"] = {
kind = "numeric",
args = { number = 1500 }
}
sequence(subsequence.id, variable)
rpc()
- 将 CeleryScript 节点包装到 中rpc_request并执行它。
command = {
kind = "wait",
args = {
milliseconds = 500
}
}
rpc(command)
cs_eval(celeryscript_ast)
执行任意 CeleryScript 节点。
在大多数情况下,你应该使用rpc()函数而不是cs_eval()。不建议使用cs_eval()未正确将命令包装到的函数rpc-request,并且可能不会起作用。
cs_eval({
kind = "rpc_request",
args = {
label = "example",
priority = 500
},
body = {
{
kind = "move_absolute",
args = {
location = {kind = "coordinate", args = {x = 2, y = 2, z = 2}},
offset = {kind = "coordinate", args = {x = 0, y = 0, z = 0}},
speed = 100
}
}
}
})
-- Execute a subsequence
subsequence = variable("Subsequence")
cs_eval(subsequence)
gcode(命令,参数)
- 将原始 G 代码发送到 Farmduino。不会应用任何验证。该函数将阻止调用过程,直到收到固件的响应。
-- Send "G00 X1.23 Y4.56 Z7.89" to the Farmduino
gcode("G00", { X = 1.23, Y = 4.56, Z = 7.89 })
获取最新文章: 扫一扫右上角的二维码加入“创客智造”公众号