Jump to content




Manipulating a value inside several nested tables


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

#1 moomoomoo3O9

  • Members
  • 82 posts
  • LocationPork roll land

Posted 10 August 2014 - 11:05 PM

Alright, so I'm loading a table containing NBT data for a block, which means it has to have the coordinates changed accordingly. Unfortunately, the table looks something like this:


Clipboard=
{[1]={["NBT"]={
type="compound",
value={
  id={type="string", value="Chest"},
  x={type="int", value=0},
  y={type="int", value=128},
  z={type="int", value=0},
  Items={
   type="list",
   value={
		{
		 type="compound",
		 value={
		  id={type="short", value=7},
		  Count={type="byte", value=64},
		  Damage={type="short", value=0},
		  Slot={type="byte", value=0}
		 }
		},
		{
		 type="compound",
		 value={
		  id={type="short", value=1},
		  Count={type="byte", value=32},
		  Damage={type="short", value=0},
		  Slot={type="byte", value=2}
		 }
		}
   }
  },
  randomLong={type="long", value={1, 2}},
  randomIntArray={type="intArray", value={1, 2, 3, 4}},
  randomByteArray={type="byteArray", value={5, 6, 7, 8}}
}
}
}
}

(If there are some curly braces missing, that isn't the problem, because I was modifying this table manually so it would look like the output of the program, as I can't test in-game at the moment)

Clipboard[1]["NBT"]["value"]["x"]["value"]=1
Clipboard[1]["NBT"]["value"]["y"]["value"]=2
Clipboard[1]["NBT"]["value"]["z"]["value"]=3

Any of those three lines will simply erase most of the table, leaving none of the other data. What should be done to fix that? How can one manipulate tables in such a way to make that work?

Edited by moomoomoo309, 11 August 2014 - 03:02 AM.


#2 Bomb Bloke

    Hobbyist Coder

  • Moderators
  • 7,099 posts
  • LocationTasmania (AU)

Posted 11 August 2014 - 07:17 PM

Those commands should only affect the specific variables within the tables that they reference - I suspect you're either misinterpreting the initial table state, or the results, or you're doing something else entirely to the table somewhere else in your code.

Otherwise you seem to have the right idea, but it's possible reading this will help you.

#3 moomoomoo3O9

  • Members
  • 82 posts
  • LocationPork roll land

Posted 12 August 2014 - 01:16 AM

That is unusual. I have no clue what caused that bug, but it is solved...

In a completely unrelated issue, I have no idea how NBT is supposed to work in Immibis Peripherals, but that is a question for Immibis, not anyone here.





2 user(s) are reading this topic

0 members, 2 guests, 0 anonymous users