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