Hello
I am trying to create a script for adding different subpalettes lika a library for brushes, and so far it’s going well but I’ve gotten into a couple of problems, so far nothing that can’t be solved but I’ve ended up with several cases of quite ugly code…
Here is my latest example: I want to create multiple subpalettes in the same menu. So I have made a test with a button that asks the user for a new palette name and it creates it, but it only works once.
So I created an array with different names for the subpalettes and creating each individual one is no problem if they are hard coded, but once I do it with a loop I only get the first. It seems that every [ISubPalette] command can only produce one subpalette.
Can someone explain why this is the case? And better yet, if there is workaround or method for this.
I assume it has something to do with the ID’s of the palettes, and a limitation of Zscript not being very friendly to object oriented programming.
I’ve added a small example you can try out, it will create som subpalettes in the edit menu when run.
[RoutineDef, run,
[Vardef, #pal_names(3)] // Array with names of the palettes
[VarSet, #pal_names(0), First]
[VarSet, #pal_names(1), Second]
[VarSet, #pal_names(2), Third]
//[Loop, 3,[ISubPalette, [StrMerge,Edit:,#pal_names(i)], 0],i] //enabling this does only produces one subpalette!
[ISubPalette, [StrMerge,Edit:,#pal_names(0)], 0]
[ISubPalette, [StrMerge,Edit:,#pal_names(1)], 0]
[ISubPalette, [StrMerge,Edit:,#pal_names(2)], 0]
]
[RoutineCall, run]