Computer API

From ComputerCraft
Jump to navigation Jump to search
FunctionFunctioncomputer.getID
Returns the ID of a computer.
Syntax computer.getID()
Returns number id
Part of CC:Tweaked (source)
API computer
ExampleExampleGet the Computer ID
Get the computer ID and print it.
Code
local computer = peripheral.find("computer")
print(computer.getID())
Output
0


FunctionFunctioncomputer.getLabel
Returns the label of a computer peripheral. Returns nil, if the computer has no label.
Syntax computer.getLabel()
Returns string label
Part of CC:Tweaked (source)
API computer
ExampleExampleGet computer label
Get computer label and print it.
Code
local computer = peripheral.find("computer")
print(computer.getLabel())
Output
Computer123


FunctionFunctioncomputer.isOn
Returns if a computer peripheral is running.
Syntax computer.isOn()
Returns boolean isOn
Part of CC:Tweaked (source)
API computer
ExampleExampleChecks if a Computer is running
Checks if a Computer is running and print it.
Code
local computer = peripheral.find("computer")
print(computer.isOn())
Output
true


FunctionFunctioncomputer.reboot
Reboot a computer peripheral.
Syntax computer.reboot()
Returns nil
Part of CC:Tweaked (source)
API computer
ExampleExampleReboot a Computer
Reboot a Computer.
Code
local computer = peripheral.find("computer")
computer.reboot()


FunctionFunctioncomputer.shutdown
Shutdown a computer peripheral.
Syntax computer.shutdown()
Returns nil
Part of CC:Tweaked (source)
API computer
ExampleExampleShutdown a Computer
Shutdown a Computer.
Code
local computer = peripheral.find("computer")
computer.shutdown()


FunctionFunctioncomputer.turnOn
Turns a computer peripheral on.
Syntax computer.turnOn()
Returns nil
Part of CC:Tweaked (source)
API computer
ExampleExampleTurn a Computer
Turn a Computer.
Code
local computer = peripheral.find("computer")
computer.turnOn()