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 01:39]
payonel
api:robot [2024/01/19 06:18] (current)
bioscreeper Grammar Improvements
Line 2: Line 2:
 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.
  
-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.+This is the api you are using when in your lua code you call
  
-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.+<code lua> 
 +local robot_api = require("​robot") 
 +robot_api.forward() 
 +</​code>​
  
-See [[block:robot|Robot Block]] for additional information on the actual Robot.+As opposed to using the robot component api directly, via the component interface
  
-==== Slot alignment ==== +<code lua> 
-The Robot'​s GUI displays the slots of a robot aligned from top-left to bottom-right. So for example the slot at index 1 is displayed in the top-left cornerthe slot at index 2 is the next to the right and the first slot on the 2nd row is index 5+local component ​require("​component"​) 
 +local robot_component_api = component.robot -- if using openoselse component.proxy(component.list("​robot"​)()) 
 +robot_component_api.move(sides.front) 
 +</​code>​
  
-{{api:robot_slotalign.png}}+While the component robot has more generic functions like `move([sidenumber])` 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.
  
-How many slots a robot has available depends on it's setup. If a slot is specified in a function that exceeds ​the amount of slots a robot has available ​an error is thrown.+Note that 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.
 +
 +==== Slot alignment ====
 +{{page>​component:​inventory_slots&​noheader&​nofooter}}
 ==== Movement ==== ==== Movement ====
  
Line 86: 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.  ​+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.  ​
Line 200: Line 210:
 - `robot.fillDown([count:​number]):​boolean`  ​ - `robot.fillDown([count:​number]):​boolean`  ​
   Like `fill`, but operates on the block below the robot.   Like `fill`, but operates on the block below the robot.
-  ​+
 Contents Contents
 ----------- -----------
 {{page>​api:​contents&​noheader&​noeditbutton&​nouser&​nofooter}} {{page>​api:​contents&​noheader&​noeditbutton&​nouser&​nofooter}}