Posted 13 June 2013 - 11:29 AM
So I have this :
First i make sure that World has a table in it called Tile, then I made a table TileM with pre-added tables.
Now i want to insert a "Tile" inside of World.Tile, so i used table.insert(etc)
Now i wish to edit the Xpos of each object i added, so i used World.Tile.Xpos = Value
I could have used this in place of the index where ever a integer index is given : #World.Tile.
Now my issue is when i have the values printed out, the Xpos's are the same for "Tiles" that are named the same (in this case numbers 1 and 4 are same, 2 and 3 are same (1+4 are redBrick,2+3 are Grass)
So i will get this printed :
1 : redBrick X : 4
2 : Grass X : 3
3 : Grass X : 3
4 : redBrick X : 4
where instead i want this output :
1 : redBrick X : 1
2 : Grass X : 2
3 : Grass X : 3
4 : redBrick X : 4
—–
What is causing this ? As i need a way to insert tiles into World.Tile, and table.insert ALLWAYS does this for like named Tiles even though those tiles are of a different index…
term.clear()
term.setCursorPos(1,1)
World = {
Tile = {
}
}
TileM = {
redBrick = {signedName = "redBrick",script = "#none",Xpos = 0,Ypos = 0,graphic = "=",color = colors.red,pixel = "#none",Solid = true},
Grass = {signedName = "Grass",script = "#none",Xpos = 0,Ypos = 0,graphic = "#",color = colors.red,pixel = "#none",Solid = true},
}
_table = TileM.redBrick
table.insert(World.Tile,1,_table)
_table = TileM.Grass
World.Tile[1].Xpos = 1
table.insert(World.Tile,2,_table)
World.Tile[2].Xpos = 2
_table = TileM.Grass
table.insert(World.Tile,3,_table)
World.Tile[3].Xpos = 3
_table = TileM.redBrick
table.insert(World.Tile,4,_table)
World.Tile[4].Xpos = 4
for k,v in pairs(World.Tile) do
print( k .. " : " .. v.signedName .. " X : " .. v.Xpos)
end
First i make sure that World has a table in it called Tile, then I made a table TileM with pre-added tables.
Now i want to insert a "Tile" inside of World.Tile, so i used table.insert(etc)
Now i wish to edit the Xpos of each object i added, so i used World.Tile.Xpos = Value
I could have used this in place of the index where ever a integer index is given : #World.Tile.
Now my issue is when i have the values printed out, the Xpos's are the same for "Tiles" that are named the same (in this case numbers 1 and 4 are same, 2 and 3 are same (1+4 are redBrick,2+3 are Grass)
So i will get this printed :
1 : redBrick X : 4
2 : Grass X : 3
3 : Grass X : 3
4 : redBrick X : 4
where instead i want this output :
1 : redBrick X : 1
2 : Grass X : 2
3 : Grass X : 3
4 : redBrick X : 4
—–
What is causing this ? As i need a way to insert tiles into World.Tile, and table.insert ALLWAYS does this for like named Tiles even though those tiles are of a different index…