Page 1 of 1

why does setlayerstyle not accept createlayer ID?

Posted: Mon Jun 11, 2018 9:07 pm
by Bugala
What am I doing wrong in here, or is this some sort of bug?
  • EnableLayers()
    n = CreateTextObject(Nil, "yea", color=#BLACK)
    SetLayerStyle(n, {text="no"})
It complains "String or number expected in argument 1!"

Re: why does setlayerstyle not accept createlayer ID?

Posted: Mon Jun 11, 2018 11:27 pm
by Bugala
Forgot to add one line to show that it works in other place:

Code: Select all

EnableLayers()
n = CreateTextObject(Nil, "yea", color=#BLACK)
DisplayTextObject(n, 100, 100)
SetLayerStyle(n, {text="no"})
So createtextobjecst output works when using DisplayTextObject, but it wont work when using setlayerstyle?

Re: why does setlayerstyle not accept createlayer ID?

Posted: Tue Jun 12, 2018 9:23 am
by Bugala
I got round the problem and probably figured what half the problem was too.

Displaytextobject makes a textout layer, hence i had to figure out the ID of that new layer.

I took it by looking what is the highest numbered layer attached to that bgpic, but is there a better way to do it?

Displaytext dont seem to return the id of the layer it creates, but is there a way to give that textout layer a name when creating it, like "DisplayTextObject(1, 100, 100, {name="myname"})"?

Re: why does setlayerstyle not accept createlayer ID?

Posted: Tue Jun 12, 2018 12:27 pm
by jPV
DisplayTextObject(n, 100, 100)
SetLayerName(0, "mytextlayer")

ID 0 in SetLayerName modifies the last added layer.

Re: why does setlayerstyle not accept createlayer ID?

Posted: Tue Jun 12, 2018 1:35 pm
by Bugala
Ah, thats a good tip. I had missed that 0 option.

Re: why does setlayerstyle not accept createlayer ID?

Posted: Tue Sep 17, 2019 11:22 pm
by Clyde
Thanks a lot, jPV! I also missed that 0 option (that should be highlighted definitely better in the documentation, it is easy to overread) and wonder and tried exactly like Bugala.
Glad I used the board search. :-)