Always top indicator script
Always top indicator script
The first of the list of scripts from my new screen https://plus.google.com/105066926163073195690/posts/h2ABxYf2F5B (with template download link)
This is a script that places an item as an indicator always on top, that is replaced by the next one when reached.
This time I added annotations in the video (made with scripts, of course đ but to sum them here:
Instructions:
– Label the items “indicator 0”, “indicator 1”, and so on starting from top, otherwise it will behave wrong.
– Unzoom (or zoom) to move all the items to their positions. Use this specially when editing.
– Newly created items are prepared (tag saved and detached from grid) automatically. But
– To modify a previously saved one, run the script from the item (to save only that item), or from the container (to save all items, make sure all are in the right position)
Important note:
For me it works smooth and lag-free with 3,4 items. Didn’t tested with more but if it works slow for you, try to change the AUTOREFRESH to false, keeping in mind you will need to run the script after any change you make, even when adding new items.
]]>
< ![CDATA[
//Indicators by +TrianguloY
/*Reminder:
the items need to be labeled “indicator 0” “indicator 1” “indicator 2” …
Unzoom (or zoom) to move all indicators to their original positions, then you can edit easily.
Running the script in the container (save all) or item (save that item) to force a save of the position of the indicator. Use this after modifying manually one. (not necessary with newly created ones)
Set the AUTOREFRESH to true if you have a lot of indicators and it lags a bit. Keep in mind you will need to unzoom/force a save/restart the launcher to apply new changes
*/
var AUTOREFRESH = true;
var ev=LL.getEvent();
var cont=ev.getContainer();
var cy=cont.getPositionY();
//flags
var inactive=cont.getPositionScale()!=1;//to disable when zoom
var reset=ev.getSource()!=”C_POSITION_CHANGED”;//to reset at desired
var resetid=-1;
if(reset&&ev.getItem()!=null){resetid=ev.getItem().getId();reset=false;}
if(AUTOREFRESH||reset||resetid!=-1||!(“indicator_items” in this)){
//create the array of indicators (indicator_items)
indicator_items=[];
var l=0;
while(true){
var p=cont.getItemByName(“indicator “+l);
if(p==null)break;
indicator_items[l++]=p;
}
}
//asignating position
var last=Math.infinity;
for(var t=indicator_items.length-1;t>=0;–t){
var item=indicator_items[t];
var iy=getiy(item);
var ny;
if((cy< =iy&&t!=0)||inactive||reset){
//set the item in their position
ny=iy;
}else{
//set the item above the previous one
var o=item.getHeight()-last;
ny=cy-(o>0?o:0);
}
//set and save
item.setPosition(item.getPositionX(),ny);
last=ny-cy;
}
function getiy(item){
//get the saved tag, otherwise, prepare the item;
var d=item.getTag(“indicator”);
if(d!=null && !reset && resetid!=item.getId())return parseInt(d);
//if no tag found or reset active
d=item.getPositionY();
item.setTag(“indicator”,d);
item.getProperties().edit().setBoolean(“i.onGrid”,false).commit();//properties set
return d;
}
]]>
< ![CDATA[
Wow! That’s really sleek! I can see this being extremely useful when grouping items together. Thank you.
]]>
< ![CDATA[
Excelente!
]]>
< ![CDATA[
Wow that’s greeaaat!!!!
]]>
< ![CDATA[
you have a lots of scipts !
]]>
< ![CDATA[
71, checked right now.
I should make a clean, I have almost all I published, some personal ones, some from the repository, and some ‘tests’.
But….
]]>
< ![CDATA[
Are all of your scripts on the wiki? Id like to go through them.
]]>
< ![CDATA[
I tried to publish there all, but maybe I missed some. If you miss someone specific just ask.
]]>
< ![CDATA[
TrianguloY awesome, thanks!
]]>
< ![CDATA[
Annotations were sweet!
]]>