Openperipheral mech

From DarkServerUK Wiki
Revision as of 23:18, 13 December 2013 by Darkrising (talk | contribs)
Jump to: navigation, search


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>

Unformatted this is just a heep of functions on your screen, so I replace the spaces with page returns. <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>