what id means in [id] = LoadAnim(id, filename$[, table])?

Discuss any general programming issues here
Post Reply
Bugala
Posts: 1178
Joined: Sun Feb 14, 2010 7:11 pm

what id means in [id] = LoadAnim(id, filename$[, table])?

Post by Bugala »

I had this piece of code:

Code: Select all

newlayerid=LoadAnim(Nil, "temp.jpg")
	DebugPrint(newlayerid)
what i was expecting was number like 1

but instead i get:
UserData: 047631E0

What does this id mean actually, and is this right?
User avatar
airsoftsoftwair
Posts: 5443
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: what id means in [id] = LoadAnim(id, filename$[, table])

Post by airsoftsoftwair »

Yes, this is right. When using the automatic ID selector Hollywood will return an identifier that uses the special data type #LIGHTUSERDATA. This has the advantage that there can never be any conflict with numeric IDs.
Bugala
Posts: 1178
Joined: Sun Feb 14, 2010 7:11 pm

Re: what id means in [id] = LoadAnim(id, filename$[, table])

Post by Bugala »

How can i use it in practice then?

For when i try:

Code: Select all

ShowLayerFX(newlayerid, {Type = #ZOOMCENTER, Speed=10})
i receive an error message saying: "String or number expected in argument 1!"
Bugala
Posts: 1178
Joined: Sun Feb 14, 2010 7:11 pm

Re: what id means in [id] = LoadAnim(id, filename$[, table])

Post by Bugala »

hmm, found from user manual about that #LIGHTUSERDATA.

I guess this is a bug in ShowLayerFX command that it doesnt work with that.

I am using Hollywood 5.3

edit: Just checked with "Showlayer(id)" command, doesnt work with that either.
Bugala
Posts: 1178
Joined: Sun Feb 14, 2010 7:11 pm

Re: what id means in [id] = LoadAnim(id, filename$[, table])

Post by Bugala »

Seems this #LIGHTUSERDATA works on some commands, but not all.

These two seem to work with that:
ScaleAnim
MoveAnim

And SetLayerName refuses to work with that.
User avatar
airsoftsoftwair
Posts: 5443
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: what id means in [id] = LoadAnim(id, filename$[, table])

Post by airsoftsoftwair »

Layers don't support this. They don't use the standard object allocator but are numbered from 1...N. Alternatively, they can also use names but they will still be numbered from 1..N. A layer's ID always reflects its position in the stack of layers, i.e. 1 is the bottom-most layer.
Bugala
Posts: 1178
Joined: Sun Feb 14, 2010 7:11 pm

Re: what id means in [id] = LoadAnim(id, filename$[, table])

Post by Bugala »

So what is the use for that automatic ID receiving, if i cant really use it anywhere?
PEB
Posts: 569
Joined: Sun Feb 21, 2010 1:28 am

Re: what id means in [id] = LoadAnim(id, filename$[, table])

Post by PEB »

Using Nil to create an id of type #LIGHTUSERDATA will give you a reference to be used any time that an object id would be used. Layer numbers are much different than object ids, since they refer to order in the layer stack (which is always subject to change). Of course, layer names can be assigned; but those names are of type #STRING and would never be used in place of object ids.

Object ids can certainly be used together with layers, but just don't confuse them with layer names. Try out this code, and see if it makes sense:

Code: Select all

EnableLayers()
TestBrushOne=LoadBrush(Nil, "Test.png")
TestBrushTwo=LoadBrush(Nil, "Test2.png")
DisplayBrush(TestBrushOne, 10, 10, {Name="TestLayer"})
WaitLeftMouse()
SetLayerStyle("TestLayer", {ID=TestBrushTwo})
User avatar
airsoftsoftwair
Posts: 5443
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: what id means in [id] = LoadAnim(id, filename$[, table])

Post by airsoftsoftwair »

Bugala wrote:So what is the use for that automatic ID receiving, if i cant really use it anywhere?
You can use it anywhere except with layers :)
Post Reply