电脑提供了许多API回调。请注意这些函数只可以被电脑自身或与其直接相邻者(即与此电脑共面的电脑)调用。还请注意因为机器人不能与外界组件交互,它们也就不能关闭/开启电脑或查询其属性,不过电脑可以与其旁边的机器人交互。
组件名:computer。
回调函数:
start(): booleantrue,否则返回false。请注意若电脑已经在运行,此函数也会返回false。若电脑正在关机过程中,此函数会使电脑改为重启。stop(): booleantrue,否则返回false。若电脑已经关闭也会返回false。isRunning(): booleanbeep([frequency:number[, duration:number]])frequency),长度(duration)最大为5秒。getDeviceInfo(): tablecrash(reason: string)getArchitecture(): stringisRobot(): boolean使用例:
local component = require("component") local c = component.computer --获取首选电脑组件,例如自身 print(c.isRunning()) --如果c是这台电脑那当然为true c.stop() --如果c是这台电脑的话,大体相当于computer.shutdown(),