Jump to content




Turtle NBT editor Peripheral [Suggestion][WIP]


  • You cannot reply to this topic
24 replies to this topic

#21 xuma202

  • Members
  • 288 posts
  • LocationBonn Germany

Posted 07 February 2013 - 05:03 AM

View PostCloudy, on 07 February 2013 - 04:40 AM, said:

Not possible with the CC API.

You mean passing an array to a peripheral function?

Well I could create an API that turns the array into a string or splits it up over several parameters and then sends it to the peripheral where it gets turned into a map again.

#22 xuma202

  • Members
  • 288 posts
  • LocationBonn Germany

Posted 07 February 2013 - 05:51 AM

Update: I've redone some things. Now getNBTData will return a table directly. Next is redoing the setNBTData so you can just pass in the modified array.

This is how the serialized table looks likes:

open for screenshot
Spoiler


#23 PixelToast

  • Signature Abuser
  • 2,265 posts
  • Location3232235883

Posted 07 February 2013 - 06:45 AM

awesome :D

#24 xuma202

  • Members
  • 288 posts
  • LocationBonn Germany

Posted 09 February 2013 - 03:05 AM

UPDATE: Ok this was a real lot of work. I've created a concept to send the array to the Peripheral and it worked, until I ran into problems because lua was not able to handle all the parameters.
I've tried different stuff some of which I didn't liked from the beginning on. I tried a JSON String but it didn't work for some reason. What I ended up with is not the prettiest and best solution but it works and is an ok compromise.

How it works (may be interesting for other modders as well:

I use a lua JSON api to convert my table into a JSON string. (http://regex.info/blog/lua/json)
Next I save the table to a file and call my peripheral function with the name of that file.
In Java I load the file and convert it to a HashMap (http://wiki.fasterxm...onInFiveMinutes)

String p = ModLoader.getMinecraftInstance().getMinecraftDir() + "\\saves\\" + myTurtle.getWorld().getWorldInfo().getWorldName() + "\\computer\\" + (String) arguments[0];

  File f = new File(p);
  Map m1 = new ObjectMapper().readValue(f, HashMap.class);

Now I recursively turn this HashMap into an NBTTag which I then write to the TileEntity.
In lua I now delete the temporary file.

For the non-developers:

You can now simply manipulate the table and call a function from the api :D

Now I'll quickly write an api and make a separate thread in the peripheral section.

#25 xuma202

  • Members
  • 288 posts
  • LocationBonn Germany

Posted 09 February 2013 - 06:27 AM

Ok it's released http://www.computerc...__fromsearch__1





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users