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.
Line 81: Line 96:
 As `robot.compare` just for the block directly below the robot. As `robot.compare` just for the block directly below the robot.
 - `robot.drop([count:​ number]): boolean`  ​ - `robot.drop([count:​ number]): boolean`  ​
-Tries to drop items from the currently selected inventory slot in **front** of the robot. Note that if you are tring to drop items into an inventory below you, this is the wrong method. Use `dropDown` for that case. This method, `drop`, will drop the items to the **front**.  ​+Tries to drop items from the currently selected inventory slot in **front** of the robot. Note that if you are trying ​to drop items into an inventory below you, this is the wrong method. Use `dropDown` for that case. This method, `drop`, will drop the items to the **front**.  ​
 **count** - specifies how many items to drop. If omitted or if count exceeds the amount of items in the currently selected slot, then all items in the currently selected slot are dropped.  ​ **count** - specifies how many items to drop. If omitted or if count exceeds the amount of items in the currently selected slot, then all items in the currently selected slot are dropped.  ​
 **Returns** `true` if at least one item was dropped, `false` otherwise.  ​ **Returns** `true` if at least one item was dropped, `false` otherwise.  ​