Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
api:robot [2018/09/27 03:06]
payonel
api:robot [2024/01/19 06:18] (current)
bioscreeper Grammar Improvements
Line 1: Line 1:
 ====== Robot API ====== ====== Robot API ======
 This API wraps the functionality of the **component** [[component:​robot|robot]] to allow more intuitive interaction with the robot. This API wraps the functionality of the **component** [[component:​robot|robot]] to allow more intuitive interaction with the robot.
 +
 +This is the api you are using when in your lua code you call
 +
 +<code lua>
 +local robot_api = require("​robot"​)
 +robot_api.forward()
 +</​code>​
 +
 +As opposed to using the robot component api directly, via the component interface
 +
 +<code lua>
 +local component = require("​component"​)
 +local robot_component_api = component.robot -- if using openos, else component.proxy(component.list("​robot"​)())
 +robot_component_api.move(sides.front)
 +</​code>​
  
 While the component robot has more generic functions like `move([side:​ number])` or `drop([side:​ number])`, this API has more intuitive and failsafe functions like `turnRight`,​ `dropDown`, `forward`. Which one you use is up to you, you can even use both at the same time. While the component robot has more generic functions like `move([side:​ number])` or `drop([side:​ number])`, this API has more intuitive and failsafe functions like `turnRight`,​ `dropDown`, `forward`. Which one you use is up to you, you can even use both at the same time.
  
-Note that a Robot is an OpenComputer ​like any other with just an additional robot component included, so the normal [[:​api|APIs]] are available as usual.+Note that a Robot is also computer ​like any other with just an additional robot component included, so the normal [[:​api|APIs]] are available as usual.
  
 See [[block:​robot|Robot Block]] for additional information on the actual Robot. See [[block:​robot|Robot Block]] for additional information on the actual Robot.