May 30

MineCraft Turtle Code – Tree Harvester!

Well few months ago I talked about playing MineCraft and how I have been playing with the turtles within the game from the fun mod ComputerCraft. Well I am back today to show you something that I created and will be expanded on when time permits to allow for Automatic tree harvesting of any tree type in the game. Right now all the code does is allow for 4×4 trees IE Fir and Redwood. The code has changed from the first bit I created back in march to allow for the harvesting of Redwood trees and not just Fir trees.

Have fun with this code feel free to expand on this but do keep the comments within it as they are and just add-on to it. Please check back here for updates to this code and look at the git hub site on the left menu bar for the newest code.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
--[[
 
  Automated Tree Logger v0.4
  Created: 1/6/2013 22:10 PST
  Updated: 5/30/2013 09:00 PST
  Created By: Proopai
  Description: This program is used to automatically chop down fir trees.  It is the first step in a fully automated Wood Farming Farm.
	       This will be expanded out to allow the Turtle to dump the logs into a sorting chest and then refill fuel, bonemeal, and saplings
	       as needed.
 
  Future Features
  ---------------------------
   - Wireless Control
   - Refuling and Fuel checks
   - Item Sorting
   - Automatic Planting
   - Automatic Tree Growth
   - Ability to cut Different Tree Types
 
  2/25/2013 Update
  ---------------------------
  Placed so that if you put a chest to the left of the turtle it will drop everything off from Slot 2 on.  This might
    in the future to allow for the ability of adding saplings and bone meal to allow for automated planting and
    tree creation.  Currently the only problem is when you have to many leaves in the sky the tree will not plant.
    This currently works for all trees with 4 section bases.  I will be making a automated tree harvester for single
    trunk trees.
 
  5/30/2013 Update
  ---------------------------
  With changing of the compareUp() to detectUp() it will allow the ability to cut down any 4x4 tree.  The next update
   will have the addition of refueling and fuel level check.  Along with Redstone signaling to allow for remote monitoring
   of the turtle with a computer and redstone network.
 
--]]
 
e = 0
 
while e <= 9 do
  turtle.forward()
  e = e + 1
end
 
turtle.dig()
turtle.forward()
turtle.select(2)
turtle.turnLeft()
 
i = 0
 
while turtle.detectUp() do
  turtle.digUp()
  turtle.dig()
  turtle.up()
  i = i + 1
end
 
turtle.dig()
turtle.turnRight()
turtle.dig()
turtle.forward()
turtle.turnLeft()
 
while i >=1 do
  turtle.dig()
  turtle.digDown()
  turtle.down()
  turtle.dig()
  i = i - 1
end
 
turtle.turnLeft()
turtle.forward(10)
turtle.turnLeft()
 
d = 0
 
while d <= 16 do
  turtle.drop(d)
end
 
turtle.turnLeft
May 15

Eve-Online API – To use Pheal or just Straight XML – PHP Turtorial

Well hello everyone! Today I am going to talk about a game that I play Eve-Online.  This game is quite nice as it has the ability to allow users who program a option to get in-game information from outside of the game through the use of an API Service.  This API Service gives you information out of the game in the form of XML.  XML is a language that allows for easy modification and manipulation of the data from a external source.  Below i have a output of what the XML looks like when you request the /account/APIKeyInfo.xml.aspx page of the Eve-Online API.  Please note if your going to use the API make sure you have an active account or someone who will give you access to their API key to test things with.

1
2
3
4
5
6
7
8
9
10
11
<eveapi version="2">
  <currentTime>2013-05-15 20:19:27</currentTime>
  <result>
    <key accessMask="134217727" type="Account" expires="">
      <rowset name="characters" key="characterID" columns="characterID,characterName,corporationID,corporationName">
        <row characterID="197034586" characterName="Devilen" corporationID="98180021" corporationName="Worm-Tech Inc."/>
      </rowset>
    </key>
  </result>
  <cachedUntil>2013-05-15 20:24:08</cachedUntil>
</eveapi>

Now that we have this information it is time to decide are we going to use PHP SimpleXML or Pheal.  The difference is Pheal has everything nicely placed for you so that you don’t have to deal with navigating the XML mine field.  Now if you go with SimpleXML you will be able to just directly access the XML that is sent to you and will be forced to handle any and all errors with the XML from CCP (The company that produces and makes Eve-Online).
Example of Pheal:

1
2
3
4
5
6
7
8
9
10
11
12
<?php
  require_once "pheal/Pheal.php";
  spl_autoload_register("Pheal::classload");
 
  $pheal = new Pheal("KeyID", "vCode"); // note you will need to put your own KeyID and vCode in.
 
  $result = $pheal->Characters();
 
  foreach ($result->characters as $characters) {
    echo $character->name."<br>";
  }
?>

What this does will go grab that API Key page using Pheal and it will then take the XML and only grab out for you the Character’s name but only the name so as you can see there are other fields too you can use $character->characterID to get the ID of that Character or $character->corporationName to get the name of the corporation the character is part of or even just grab the information and throw it all into a database to call it back later as this is static information.
Example of SimpleXML:

1
2
3
4
5
6
7
8
<?php
  $apiSite = "https://api.eveonline.com/account/APIKeyInfo.xml.aspx?keyID=&vCode="; // note you will need to put your own KeyID and vCode in.
  $xml = simplexml_load_file($apiSite);
 
  foreach($xml->result->key->rowset->row as $rows){
     echo $rows->attributes()->characterName."<br>";
  }
?>

What is going on is this will go to the site that you put in and grab the output based off the url. This can be a problem if you don’t type in the url correctly or fail to put the correct keyID and vCode in. Then it grabs the XML places it into the place holder of $xml and you then loop the entry of row so it will grab all the characters within the account. You can only have 3 characters per account.

Right now most people will agree when I say that Pheal is simple and less knowledge needed for getting the data out of the xml documents that you have to parse from the Eve Servers. Some might say well the SimpleXML has less lines of code and it looks straight forward. I would agree both are simple and with the exception of Pheal allowing you to change any the URL’s for whats needed by using the $pheal->scope function it is actually a pretty good library. This something you will have to do manually with SimpleXML by editing the URL For the tutorial going forward I will continue to use the Pheal api library and when needed show the SimpleXML counterpart.

If you have anything that you would like to see based off this tutorial let me know and I will see what can be done and if there are any tutorials that I can do for everyone.

May 08

Updates and Cloudflare

Well as the title says I have been playing around with the site a bit and it has some updates done to it and the most important one of all is the fact that it has been enabled to use CloudFlare to help the site serve what is needed quicker and more effective.

I am looking to get more information up here soon as possible a contact me page and a donation page to help cover the costs of the site and projects I will be starting and writing up how to’s on.  If you help donate to them you will be given the ability to have a shot at owning the final product when it is completed.  More about this in the next few months as it is something I am working on.

I am also going to be adding Small Adverts around the site to help cover the costs of development of the site and managing it.  So don’t feel the need to have to click on them but if there is something you want then feel free to click on it.

Also more Programming Code to be posted here and uploaded.  I will be writing how to on how to use XML to grab API data information from the Eve API along with how to use the Pheal and PhealNG library’s if your not sure.  Along with more Arduino and some Python code as I learn it my self.  I will also upload my Objective-C Code from my iPhone and iPad Programming.

I hope that everyone is doing well and post soon!