Code: Select all
Walls= {}
Walls[1] = {hp=100}
Walls[2] = {hp=150}
StartX = 100
SpaceBetween = 200
Y = 300
Function DrawOnTopOfWall(Wall)
GFX.DisplayBrush(StartX + SpaceBetween * IndexNumber, Y)
EndFunction
As in, I know first wall X will be 100, second one 300, third one 500, therefore I dont need to store those X independently, but as long as I know their index number, I can figure out their X-placing, based upon this simple formula on (StartX + SpaceBetween * Indexnumber).
But problem is in getting that IndexNumber.
As in, I want to simply access this function, by sending it a Wall Item, nothing else. But then I dont have the Index number.
So far I have had to solved this problem by for example adding IndexNumber manually there, as in:
Code: Select all
Walls= {}
Walls[1] = {hp=100, Number=1}
Walls[2] = {hp=150, Number=2}
Code: Select all
GFX.DisplayBrush(StartX + SpaceBetween * Wall.Number, Y)Therefore, If function is having Wall Item (table) as its ARG, is there any way to know at which IndexNumber this Item is residing in the table that it is residing?
As example:
Code: Select all
Function DrawOnTopOfWall(Wall)
Number = GetIndexNumberOfItem(Wall)
GFX.DisplayBrush(StartX + SpaceBetween * Number, Y)
EndFunction