This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
Agent Silence's profile picture

How to convert NBS files?

Started by Agent Silence, 25 August 2014 - 03:27 PM
Agent Silence #1
Posted 25 August 2014 - 05:27 PM
Im making an in game NBS using the Iron Noteblock from Tobit's MoarPeripherals. And I can't seem to understand how to convert saved data files to NBS. The data files are in this format :

addedKeys = {
  {
    instrument = "Piano/Harp",
    key = 3,
    octave = 1,
    page = 1,
    pos = 11,
  },
  {
    instrument = "Piano/Harp",
    key = 9,
    octave = 1,
    page = 1,
    pos = 18,
  },
  {
    instrument = "Piano/Harp",
    key = 11,
    octave = 1,
    page = 1,
    pos = 33,
  },
  {
    instrument = "Piano/Harp",
    key = 5,
    octave = 1,
    page = 1,
    pos = 33,
  },
  {
    instrument = "Piano/Harp",
    key = 3,
    octave = 1,
    page = 1,
    pos = 23,
  },
  {
    instrument = "Piano/Harp",
    key = 6,
    octave = 1,
    page = 1,
    pos = 19,
  },
}
If anyone has knowledge on how to do so, please help
Bomb Bloke #2
Posted 25 August 2014 - 07:23 PM
I can tell you that the specification is here. Bear in mind that you'll need a basic understanding of how data types relate to memory usage in order to actually do anything with that information - I suggest reading through BIT's NBS reading code in the Note player for some pointers.
theoriginalbit #3
Posted 26 August 2014 - 12:21 AM
You'll definitely have to understand Endianess and how to convert between the two as Java's IO is big endian, and the NBS format is little endian.