Tuesday 16 April 2013

The flow of power


Progress is at last significant.  I have been devoting myself to my studies, ignoring my duties, leaving those who depend on me to fend for themselves.  My studies have lost me both friends and future career prospects, but it has been worth it!  I am finally at the stage where I can bring the power of ScriptCraft to bear on the scripts in a Book and Quill object.


My beloved daughter, who helps me with my experiments in spite of her mothers objections, has created a Book and Quill object for me (I will get her to summarize how it was done in a future entry in this tome) and I managed to write the script "2+2" in it.  I have included an illustration of my success below.  This may seem like an insignificant formula, but by using ScriptCraft to transform this formula into the value 4, I have demonstrated the fundamental principles of the magic.  Thus, the power I have been seeking for all this time is within my grasp.

 










Now, for my coup de grace.  The incantation I found to work, after hours of pouring over ancient tutorials and aplication programming interfaces, was:

  /js eval(self.inventory.getItem(7).getItemMeta().getPage(1)+"")

This incantation, when entered into the Minecraft client, finds the players inventory (self.inventory) and gets the ItemStack for the 7th inventory slot.  I use this number because, as you can see in the illustration above, my book is in slot number 7 if you start counting from 0.  The getItemMeta() call gets the BookMeta object.  On that object, it then calls the getPage() method, passing the parameter 1, to get the first page.
That method is supposed to return a String that can be passed directly to the eval() method, but for some reason that does not work.  I managed to make it work by adding an empty String, i.e., the +"" part of the incantation, presumably forcing ScriptCraft to recognize that the previous expression is actually a String.

As you can see in the illustration below, this incantation has converted the formula in my book to the value 4.0!












The prospects of such power make me dizzy.  Next, I will try out some more advanced spells and hopefully be able to change the world, but I must now leave before the consequences of my absence removes me further from my studies of magic.  I shall return as soon as I have an opportunity.

Yours triumphantly,
 DigiMage

No comments:

Post a Comment