Difference between revisions of "Openperipheral mech"

From DarkServerUK Wiki
Jump to: navigation, search
Line 33: Line 33:
 
</syntaxhighlight>
 
</syntaxhighlight>
  
Unformatted this is just a heep of functions on your screen, so I replace the spaces with page returns.
+
== API ==
 +
 
 +
Please note: Each function's first parameter must be the robots ID.
 +
{| class="wikitable"
 +
|-
 +
!|Function
 +
!|Returns
 +
!|Description
 +
|-
 +
|getLocation(int id)
 +
|x,y,z coordinates
 +
|Get real world coordinates (not gps)
 +
|-
 +
|getPitch(int id)
 +
|int pitch
 +
|get current pitch
 +
|-
 +
|getYaw(int id)
 +
|int yaw
 +
|get current yaw
 +
|-
 +
|setPitch(int id, int pitch)
 +
|
 +
|set pitch
 +
|-
 +
|setYaw(int id, int yaw)
 +
|
 +
|set yaw
 +
|-
 +
|goto(int id, int x, int y, int z)
 +
|
 +
|goto real world coordinates
 +
|-
 +
|jump(int id)
 +
|
 +
|Make the mech jump!
 +
|-
 +
|getHeat(int id)
 +
|int heat
 +
|Get heat level
 +
|-
 +
|fireLight(int id)
 +
|
 +
|Fire light laser
 +
|-
 +
|fireMedium(int id)
 +
|
 +
|Fire medium laser
 +
|-
 +
|fireHeavy(int id)
 +
|
 +
|Fire heavy laser
 +
|-
 +
|isCoolEnough(int id)
 +
|boolean - true if able to fire
 +
|Checks if mech is cool enough to shoot
 +
|-
 +
|isOverheated(int id)
 +
|boolean - true if overheated
 +
|Checks if the mech is overheated
 +
|-
 +
|getMaxHeat(int id)
 +
|int maxHeatLevel
 +
|max capable heat level
 +
|-
 +
|getCoolingPerTick(int id)
 +
|int cpt
 +
|how much cooling per tick the mech is capable of
 +
|-
 +
|sonicScan(int id)
 +
|indexed table 1 - 27
 +
|Returns table of block information around the mech
 +
|-
 +
|getMinecartIds(int id)
 +
|Indexed table
 +
|Ids of all minecarts around the mech
 +
|-
 +
|getPlayerNames(int id)
 +
|Indexed table
 +
|Names of all players around the mech
 +
|-
 +
|getPlayerData(int id, string player name)
 +
|table
 +
|player data in table form
 +
|-
 +
|getMobIds(int id)
 +
|Indexed table
 +
|Ids of all mobs around the mech
 +
|-
 +
|getMobData(int id)
 +
|table
 +
|mod data in table form
 +
|-
 +
|getMinecartData(int id, int minecart ID)
 +
|table
 +
|minecart data in table form
 +
|-
 +
|refuel(int id, int slot, int amount)
 +
|
 +
|refuel mech (Doesn't seem to do much
 +
|-
 +
|getFuelLevel(int id)
 +
|int fuel level
 +
|get mech fuel level
 +
|-
 +
|aimAt(int id, x, y, z)
 +
|
 +
|Aim gun at actual world positions
 +
|-
 +
|lookAt(int id, x, y, z)
 +
|
 +
|Same as aim, but aims from the mechs head
 +
|-
 +
|}
 +
 
 +
 
 +
Here is a raw list of the functions:
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
 
getStackInSlot()
 
getStackInSlot()

Revision as of 00:08, 14 December 2013


Openperipheral Mechs (also known as OpenMech: Warrior in the creative tab)

I couldn't find much written on them, so I decided to add this to my wiki.

Information

These mechs are quite cool, you can do a lot with them. Probably even more than Computercraft Turtles, but mechs are unable to fly.

Setting up

  1. To set up your mech first grab yourself a Computercraft computer and place it on the ground.
  2. Next get yourself a "Robot Controller" and place it next to the computer
  3. Grab yourself a "OpenMech: Warrior", right click on the controller and place it inside. This will give it an ID
  4. Take the mech out of the controller and place it somewhere in the world.

You are now ready to mess around with it!

Additional information

If you right click on your mech you will notice it has an inventory, you can put ammo and upgrades in here! Search NEI for "unit" and you will see some upgrades you can put into your mech, an example being "Tier 3 Sensor Unit". These upgrades will allow you perform more functions with your mech.

The Programming

First thing you need to do is wrap the "Robot Controller" to a handler using the peripheral API. <syntaxhighlight lang="lua"> mech = peripheral.wrap("right") </syntaxhighlight>

Because OpenMech is a part of the OpenPeripheral mod we can use the function <peripheral>.listMethods to get a list of the functions for the "Robot Controller"

Using the code below I was able to get a list of methods / functions that the mech can do. <syntaxhighlight lang="lua"> methods = mech.listMethods() print(methods) </syntaxhighlight>

API

Please note: Each function's first parameter must be the robots ID.

Function Returns Description
getLocation(int id) x,y,z coordinates Get real world coordinates (not gps)
getPitch(int id) int pitch get current pitch
getYaw(int id) int yaw get current yaw
setPitch(int id, int pitch) set pitch
setYaw(int id, int yaw) set yaw
goto(int id, int x, int y, int z) goto real world coordinates
jump(int id) Make the mech jump!
getHeat(int id) int heat Get heat level
fireLight(int id) Fire light laser
fireMedium(int id) Fire medium laser
fireHeavy(int id) Fire heavy laser
isCoolEnough(int id) boolean - true if able to fire Checks if mech is cool enough to shoot
isOverheated(int id) boolean - true if overheated Checks if the mech is overheated
getMaxHeat(int id) int maxHeatLevel max capable heat level
getCoolingPerTick(int id) int cpt how much cooling per tick the mech is capable of
sonicScan(int id) indexed table 1 - 27 Returns table of block information around the mech
getMinecartIds(int id) Indexed table Ids of all minecarts around the mech
getPlayerNames(int id) Indexed table Names of all players around the mech
getPlayerData(int id, string player name) table player data in table form
getMobIds(int id) Indexed table Ids of all mobs around the mech
getMobData(int id) table mod data in table form
getMinecartData(int id, int minecart ID) table minecart data in table form
refuel(int id, int slot, int amount) refuel mech (Doesn't seem to do much
getFuelLevel(int id) int fuel level get mech fuel level
aimAt(int id, x, y, z) Aim gun at actual world positions
lookAt(int id, x, y, z) Same as aim, but aims from the mechs head


Here is a raw list of the functions: <syntaxhighlight lang="lua"> getStackInSlot() swapStacks() getInventoryName() listMethods() pullItem() pushItem() getAdvancedMethodsData() getInventorySize() condenseItems() pullItemIntoSlot() pushItemIntoSlot() getLocation() getPitch() getYaw() setPitch() setYaw() goto() jump() getHeat() fireMedium() fireHeavy() isCoolEnough() isOverheated() getMaxHeat() fireLight() getCoolingPerTick() sonicScan() getMinecartIds() getPlayerNames() getMinecartData() getMobIds() getMobData() getPlayerData() refuel() getFuelLevel() getStackInSlot() swapStacks() getInventoryName() pullItem() pushItem() drop() getInventorySize() condenseItems() suck() pullItemIntoSlot() pushItemIntoSlot() aimAt() lookAt() </syntaxhighlight>