Jump to content




Turtle NBT editor Peripheral [Suggestion][WIP]


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

#1 xuma202

  • Members
  • 288 posts
  • LocationBonn Germany

Posted 05 February 2013 - 03:18 AM

Hi,

beacuse of a bug in the current version of RedPower2 I had to manually set many RedBusIds this weekend using an InGame NBT editor which became annoying quickly. Today I came with an epic idea solving this and maybe lots of other problems. A peripheral, that can be crafted onto a turtle, that adds the following functions:

getNBTData() - would return a multidimensional Array containing the values of the NBTData of the block in front of the Turtle. (Maybe a getNBTDataUp() and getNBTDataDown())
getNBTDataTypes() - would return a multidimensional Array containing the types ("double", "byte", ...) of the NBTData of the block in front of the Turtle. (Maybe a getNBTDataTypesUp() and
getNBTDataTypesDown())
setNBTData() - would allow setting values to the NBT fields

of course the name of the functions could be different but I hope you get my point.

This peripheral would allow not only setting many RP2 BusIds but also setting much Metadata of Blocks like setting the rotation or the inventory or ....

What do you think about this idea guys?
Is someone interested/willing to create this peripheral?

Thanks in advance Chris

#2 Cranium

    Ninja Scripter

  • Moderators
  • 4,031 posts
  • LocationLincoln, Nebraska

Posted 05 February 2013 - 03:58 AM

Split to new topic in Suggestions. You do not have to post on the new members thread, since you have been here for some time. Please keep that in mind.

#3 PixelToast

  • Signature Abuser
  • 2,265 posts
  • Location3232235883

Posted 05 February 2013 - 03:59 AM

i suggested NBT editing awhile ago
its not gona happen, you can easily crash and burn a server
get someone to make a peripheral for it

#4 Cloudy

    Ex-Developer

  • Members
  • 2,543 posts

Posted 05 February 2013 - 04:18 AM

View PostCranium, on 05 February 2013 - 03:58 AM, said:

Split to new topic in Suggestions. You do not have to post on the new members thread, since you have been here for some time. Please keep that in mind.

Yes, he did. It wouldn't let him for some reason, something I'm going to look into.

#5 Cranium

    Ninja Scripter

  • Moderators
  • 4,031 posts
  • LocationLincoln, Nebraska

Posted 05 February 2013 - 04:20 AM

View PostCloudy, on 05 February 2013 - 04:18 AM, said:

View PostCranium, on 05 February 2013 - 03:58 AM, said:

Split to new topic in Suggestions. You do not have to post on the new members thread, since you have been here for some time. Please keep that in mind.

Yes, he did. It wouldn't let him for some reason, something I'm going to look into.
Then I retract my previous statement. I thought he was able to, seeing as he has been here since March.

#6 xuma202

  • Members
  • 288 posts
  • LocationBonn Germany

Posted 05 February 2013 - 04:42 AM

View PostCranium, on 05 February 2013 - 04:20 AM, said:

View PostCloudy, on 05 February 2013 - 04:18 AM, said:

View PostCranium, on 05 February 2013 - 03:58 AM, said:

Split to new topic in Suggestions. You do not have to post on the new members thread, since you have been here for some time. Please keep that in mind.

Yes, he did. It wouldn't let him for some reason, something I'm going to look into.
Then I retract my previous statement. I thought he was able to, seeing as he has been here since March.

The Problem has been fixed. I can now create threads on my own again. Thanks

#7 xuma202

  • Members
  • 288 posts
  • LocationBonn Germany

Posted 06 February 2013 - 07:29 AM

Update:

I worked on a peripheral for this. It works great. But I'm currently too lazy to write a documentation and because it can harm your minecraft world I won't release it just now. However, if you're interested in using it or develop this further here https://drive.google...WURjWjlvdDFLT0U you can find the binaries and the source code. You can use it in anyway you want but please mention my name or put a link. You can retrieve NBT data and edit values. You can't delete or create new NBT Tags or array elements.

Note it is using the Turtle Upgrade id 254 though I don't reserve it currently.

Chris

#8 PixelToast

  • Signature Abuser
  • 2,265 posts
  • Location3232235883

Posted 06 February 2013 - 08:28 AM

:D
thanks, im testing it now :3

EDIT: cant place it 3:
i tried 65024
and 254 damage values but it still reverts to a normal turtle when i place it >_>
EDIT2:
derp Dx forgot to restart server when installing
EDIT3:
this is awesome :D, toataly gona make a UI for it when i have the time
one problem: you have to do this to get the table:
loadstring(editor.getNBTData())()()


#9 Orwell

    Self-Destructive

  • Members
  • 1,091 posts

Posted 06 February 2013 - 08:32 AM

I would definitely restrict the use of this. Changing the NBT data of a chest could give me total spawn power.

#10 xuma202

  • Members
  • 288 posts
  • LocationBonn Germany

Posted 06 February 2013 - 08:41 AM

View PostPixelToast, on 06 February 2013 - 08:28 AM, said:

:D
thanks, im testing it now :3

EDIT: cant place it 3:
i tried 65024
and 254 damage values but it still reverts to a normal turtle when i place it >_>

Try crafting it using a turtle and a Bottle o' Enchanting this should work

View PostOrwell, on 06 February 2013 - 08:32 AM, said:

I would definitely restrict the use of this. Changing the NBT data of a chest could give me total spawn power.

This is intended to be used in creative only or for special purposes. I think ppl should decided on their own for what they use it. For example I used it o set many RedPower BusIds.
Of course this should not be used on a public server. But when you're building stuff alone or with friends it could be useful. However if ppl wanna use it for getting items illegally I see no reason to stop them.

#11 Orwell

    Self-Destructive

  • Members
  • 1,091 posts

Posted 06 February 2013 - 08:47 AM

View Postxuma202, on 06 February 2013 - 08:41 AM, said:

View PostPixelToast, on 06 February 2013 - 08:28 AM, said:

:D
thanks, im testing it now :3

EDIT: cant place it 3:
i tried 65024
and 254 damage values but it still reverts to a normal turtle when i place it >_>

Try crafting it using a turtle and a Bottle o' Enchanting this should work

View PostOrwell, on 06 February 2013 - 08:32 AM, said:

I would definitely restrict the use of this. Changing the NBT data of a chest could give me total spawn power.

This is intended to be used in creative only or for special purposes. I think ppl should decided on their own for what they use it. For example I used it o set many RedPower BusIds.
Of course this should not be used on a public server. But when you're building stuff alone or with friends it could be useful. However if ppl wanna use it for getting items illegally I see no reason to stop them.
I agree. I use the mod NBTEdit to change the RedPower Bus ID's in game though. :)

#12 PixelToast

  • Signature Abuser
  • 2,265 posts
  • Location3232235883

Posted 06 February 2013 - 09:13 AM

this could still corrupt maps :P

#13 xuma202

  • Members
  • 288 posts
  • LocationBonn Germany

Posted 06 February 2013 - 09:28 AM

View PostPixelToast, on 06 February 2013 - 08:28 AM, said:

EDIT3:
this is awesome :D, toataly gona make a UI for it when i have the time
one problem: you have to do this to get the table:
loadstring(editor.getNBTData())()()

Yes I know but I don't know of a better way since I can't give a table as a function return. Though I'll make an API for this. At this point I wanna thank Espen. His mod "ccDB" is using a similar technique which inspired me.


View PostPixelToast, on 06 February 2013 - 09:13 AM, said:

this could still corrupt maps :P

This is one of the reasons why it's not an officially released peripheral. :P

#14 Orwell

    Self-Destructive

  • Members
  • 1,091 posts

Posted 06 February 2013 - 09:34 AM

View Postxuma202, on 06 February 2013 - 09:28 AM, said:

Yes I know but I don't know of a better way since I can't give a table as a function return.
Returning a Map from callMethod in Java will result in returning a table in CC. The idea of key/value is the same for the Map as it is for Lua tables.

#15 PixelToast

  • Signature Abuser
  • 2,265 posts
  • Location3232235883

Posted 06 February 2013 - 09:41 AM

cant figure out the set function >_>
dosent return any useful information

#16 xuma202

  • Members
  • 288 posts
  • LocationBonn Germany

Posted 06 February 2013 - 10:04 AM

View PostOrwell, on 06 February 2013 - 09:34 AM, said:

View Postxuma202, on 06 February 2013 - 09:28 AM, said:

Yes I know but I don't know of a better way since I can't give a table as a function return.
Returning a Map from callMethod in Java will result in returning a table in CC. The idea of key/value is the same for the Map as it is for Lua tables.

Oh really?! In the javadocs it just says

Quote

Returns: An array of objects, representing values you wish to return to the lua program.
Integers, Doubles, Floats, Strings, Booleans and null be converted to their corresponding lua type.
All other types will be converted to nil.
You may return null to indicate no values should be returned.

But I'll try it. Thanks for the hint.


View PostPixelToast, on 06 February 2013 - 09:41 AM, said:

cant figure out the set function >_>
dosent return any useful information

Well, using the set function is a bit tricky. I'll give you an example:

Let's say the data is

{name="", type="TAG_Compound", value={{name="rbaddr", type="TAG_Int", value=4}, {name="x", type="TAG_Int", value=85}, {name="data", type="TAG_IntArray", value={3, 6, 9}}, {name="compound", type="TAG_Compound", value={{name="tag", type="TAG_String", value="I'm a string"}} [...]}}



rbaddr = 4

x = 85

data

3

6

9

compound

tag = I'm a string

[...]




now if you want to change the value of rbaddr you'll call setNBTTagValue(x,"rbaddr")
where x is the new value and all following parameter the name of the element.

If you'd like to change the value of a Tag inside an IntArray or ByteArray, use the name of the Array and as the next parameter the id of the field.
So changing the 6 into a 13 would be done this way:
setNBTTagValue(13,"data",1) because 1 is the index. (STARTING WITH 0 NOT WITH 1)

If you'd like to change the value of a Tag inside a compound do it this way:
setNBTTagValue("I'm another string","compound","tag")
or
setNBTTagValue(<newValue>,<name of the compound>,[<name another compound>][...],<name of the Tag>)

However, how would you'd like to set the values. Have you got a way doing this which is simpler?

Chris

#17 immibis

    Lua God

  • Members
  • 1,033 posts
  • LocationWellington, New Zealand

Posted 06 February 2013 - 12:42 PM

Here is a fix for RP screwdrivers not changing bus IDs, in a way that doesn't allow people to spawn items or crash the server: http://pastehtml.com.../cr72r0hhu.html

#18 xuma202

  • Members
  • 288 posts
  • LocationBonn Germany

Posted 06 February 2013 - 11:47 PM

This is great immibis. I've asked many times for such a fix in the redpower irc but nobody knew about this. However if you have to set hundreds of ids this mod is still useful.

#19 PixelToast

  • Signature Abuser
  • 2,265 posts
  • Location3232235883

Posted 07 February 2013 - 04:35 AM

id like to be able to modify the returned table and have the changes work instantly
local chest=peripheral.call("right","getNBTData")
chest.x.value="something"
and have a function to set the entire table because when you do
chest=table
the actual data of the chest isnt modified, its just setting the variable to a new table

#20 Cloudy

    Ex-Developer

  • Members
  • 2,543 posts

Posted 07 February 2013 - 04:40 AM

Not possible with the CC API.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users