I noticed that If I do that:
MyPic = CreateBrush(Nil, x, y, color)
and than to that lately in the program(same id name) without free the brush, Hollywood will maintain the old brush too(the resource monitor increase number of brushes in memory)...
But since I use the same name wasnt better(and natural) that the old one(with the samwe name) was deleted in automatic?
Stupid question?
Thanks!
Automatic Id question...
Automatic Id question...
Simone"Tuxedo"Monsignori, Perugia, ITALY.
Re: Automatic Id question...
Yes, Hollywood assigns a new "number" (#LIGHTUSERDATA) every time Nil is used with automatic id selection.
Re: Automatic Id question...
Yes, but...
Since the specified id was the same why dont use the same?
In that way we have duplicates whit same name...
Since the specified id was the same why dont use the same?
In that way we have duplicates whit same name...
Simone"Tuxedo"Monsignori, Perugia, ITALY.
Re: Automatic Id question...
Let me understand better:
you say that in the following code
the second brush creation should free the first one because you have used the same variable (my_brush)?
I think it's not really handy this approach... more automatic actions means less programming freedom for me you can achieve what you are looking for with a little piece of code like:
Not tried but should work, I hope to have understood your problem
you say that in the following code
Code: Select all
my_brush = CreateBrush(Nil, 100, 100)
...
my_brush = CreateBrush(Nil, 200, 150)
I think it's not really handy this approach... more automatic actions means less programming freedom for me you can achieve what you are looking for with a little piece of code like:
Code: Select all
Function CustomFreeBrush(my_holding_var)
If GetType(my_holding_var) <> #NIL Then FreeBrush(my_holding_var)
EndFunction
CustomFreeBrush(my_brush)
my_brush = CreateBrush(nil, 100, 100)
...
CustomFreeBrush(my_brush)
my_brush = CreateBrush(nil, 200, 150)
----------------------------
[Allanon] Fabio Falcucci | GitHub for recent works | Support me on Patreon for Hollywood libraries | ☆★ All my links ★☆
[Allanon] Fabio Falcucci | GitHub for recent works | Support me on Patreon for Hollywood libraries | ☆★ All my links ★☆
Re: Automatic Id question...
@Allanon
mmm...
Ok but...
There's a way to load that duplicates brushes?
Because if there wasnt a way I remain of my idea... no use that same id generates dupicates...
dont?
mmm...
Ok but...
There's a way to load that duplicates brushes?
Because if there wasnt a way I remain of my idea... no use that same id generates dupicates...
dont?
Simone"Tuxedo"Monsignori, Perugia, ITALY.
Re: Automatic Id question...
Quoting from the manual (Automatic id selection):Tuxedo wrote:Yes, but...
Since the specified id was the same why dont use the same?
In that way we have duplicates whit same name...
So using Nil causes Hollywood to choose a UNIQUE variable every time (if it were the same as the previous, then it wouldn't really be UNIQUE); it just happens to be that you are "assigning" it to the same custom variable (MyPic in your example). Andreas might want to change things to have Hollywood check to see if your custom variable already has a #LIGHTUSERDATA variable assigned to it, and then reuse it; but as of right now, Hollywood is acting as the documentation says it should.You can simply pass Nil instead of an id and Hollywood will return an id for the new object that is guaranteed to be unique because it uses the special variable type #LIGHTUSERDATA.
Re: Automatic Id question...
Hmm, Im bit of thinking you might be having thought error here tuxedo.
Its typical to have thought errors at some point of programming, like i remember in EASY AMOS having problem moving my BOBs arounf the screen, since i was thinking them like pieces of paper that are moved around, isntead of being pictures that are drawn every time.
I didnt understand at that time that everytime anything happens on screen, it needs to be completely redrawn. So i was thinking it just moves this piece of BOB graphic around the screen when moving it and hence was stuck on that for long time.
But to your precise problem.
If i rightly understood, the problem in your mind seems to be the idea that using:
X = NIL
Y = NIL
You are happy to accept that X ID is 1 and Y ID is 2.
But when using:
X = NIL
and later again:
X = NIL
you think it should be giving second X the same ID, 1.
However, if you think that logic bit differently you realise that wouldnt be practical.
First of all, the idea is, that there are basically TWO different separate commands happening.
(Left Command) = (Right Command)
So first hollywood does the RIGHT command, in which it gives next free ID because of that NIL.
After this is done, it will send the result to the LEFT command.
So when NIL command in RIGHT is done, it is totally blind to what is happening in LEFT.
Similarly LEFT command doesnt care what is coming from RIGHT side. LEFT have just decided to catch what ever it is that is coming from there.
You do know the saying Right hand doesnt know what left hand is doing. That is exactly happening here.
While it would be useful to you that NIL would check who is the catcher, it might not be useful for many others.
For example lets say theres a tetris game.
It might be handy to use variable like:
fallingpiece=NIL
in this case the pieces already down dont need to be moved anymore, so it is just natural to always just replace the variable fallingpiece to latest ID and then continue the program:
repeat
function dostuff(fallingpiece)
showlayer(fallingpiece, x, y)
until something
Hope this helped something.
Its typical to have thought errors at some point of programming, like i remember in EASY AMOS having problem moving my BOBs arounf the screen, since i was thinking them like pieces of paper that are moved around, isntead of being pictures that are drawn every time.
I didnt understand at that time that everytime anything happens on screen, it needs to be completely redrawn. So i was thinking it just moves this piece of BOB graphic around the screen when moving it and hence was stuck on that for long time.
But to your precise problem.
If i rightly understood, the problem in your mind seems to be the idea that using:
X = NIL
Y = NIL
You are happy to accept that X ID is 1 and Y ID is 2.
But when using:
X = NIL
and later again:
X = NIL
you think it should be giving second X the same ID, 1.
However, if you think that logic bit differently you realise that wouldnt be practical.
First of all, the idea is, that there are basically TWO different separate commands happening.
(Left Command) = (Right Command)
So first hollywood does the RIGHT command, in which it gives next free ID because of that NIL.
After this is done, it will send the result to the LEFT command.
So when NIL command in RIGHT is done, it is totally blind to what is happening in LEFT.
Similarly LEFT command doesnt care what is coming from RIGHT side. LEFT have just decided to catch what ever it is that is coming from there.
You do know the saying Right hand doesnt know what left hand is doing. That is exactly happening here.
While it would be useful to you that NIL would check who is the catcher, it might not be useful for many others.
For example lets say theres a tetris game.
It might be handy to use variable like:
fallingpiece=NIL
in this case the pieces already down dont need to be moved anymore, so it is just natural to always just replace the variable fallingpiece to latest ID and then continue the program:
repeat
function dostuff(fallingpiece)
showlayer(fallingpiece, x, y)
until something
Hope this helped something.