"How to call a brush?"
Idea with Brushes is that each brush has its own ID.
You could make a new brush:
And now this would be Brush number 1, in which case you could use:
You can also have more brushes, say:
Code: Select all
CreateBrush(1,10,10,#BLUE)
CreateBrush(2,10,10,#GREEN)
CreateBrush(3, 10,10,#BLACK)
And now you can use for example:
And it would now be displaying Brush number 2, which is #GREEN
Notice if you after having put those three brushes do following:
Code: Select all
CreateBrush(1,10,10,#BLUE)
CreateBrush(2,10,10,#GREEN)
CreateBrush(3, 10,10,#BLACK)
CreateBrush(1, 10,10,#WHITE)
DisplayBrush(1, 0, 0)
That would now be displaying a #WHITE brush.
This is because when you made another CreateBrush with ID 1, it replaced the old Brush ID 1, with this new brush. Hence the old Brush ID 1 (#BLUE) doesnt exist anymore.
Now, in your code you have been instead of using Direct numbers like 1, 2, 3, you have instead used NIL as the ID.
This NIL is a special case when creating Brushes (used by some other commands as well).
Idea is, that instead of you giving the brush a direct ID number, NIL is going to be giving you the first available number.
Hence for example using:
Code: Select all
CreateBrush(NIL,10,10,#BLUE)
CreateBrush(NIL,10,10,#GREEN)
CreateBrush(NIL, 10,10,#BLACK)
CreateBrush(NIL, 10,10,#WHITE)
Could in practice result in you having Brush ID 1 containing #BLUE, ID 2 containing #GREEN... But you cant know that for sure. It depends what you created before.
For example, if you already have created Brush ID 1, 2 and 3, then these four would be getting IDs 4, 5, 6, and 7.
regardless what ID they actually get, idea is not to guess them, but to store them somewhere, hence you could for example have:
Code: Select all
BlueCube = CreateBrush(NIL,10,10,#BLUE)
GreenCube = CreateBrush(NIL,10,10,#GREEN)
BlackCube = CreateBrush(NIL, 10,10,#BLACK)
WhiteCube = CreateBrush(NIL, 10,10,#WHITE)
Now since you stored them in a variable, you dont need to know their actual ID numbers anymore. You dont need to worry if BlueCube in practice is 1, 2, 3 or whatever number. All you need to know is that whatever that number is, it is stored in variable BlueCube.
And hence you can simply use:
and regardless what ever BlueCubes ID is, it is now being displayed. Just like you would be using "DisplayBrush(1, 0, 0)" (supposing BlueCube ID would be 1).
So what you effectively was doing with your table, was that you were storing these IDs in a table.
As example:
Code: Select all
MyBrushes = {}
MyBrushes[1] = BlueCube
MyBrushes[2] = GreenCube
However, as you were storing the actual ID directly to the table, in way of:
Code: Select all
MyBruhses = {}
MyBrushes[1] = CreateBrush(NIL, 10,10, #BLUE)
That table was therefore only place containing the actual ID number, and hence if you destroyed that table, or table item, there was no reliable way of getting Brushes ID anymore after that.
You could compare the situation so that you have 100s of discs, each containing only one number in them, 1, 2, 3...
In addition to this you have a notebook which reads: "My movies in alphabetical order: Ghostbusters- 23, Indiana Jones and the Raiders of the Lost ark- 97, Karate Kid- 3..."
Now if you lose your notebook. Then your Discs would still contain those movies, you just wouldnt know what each disc contains anymore, since you would only have the numbers on those discs, but you wouldnt know to what movie each number refers to. This situation is a bit similar.
Hope this explanation made you understand the situation.