now browsing by category

 

horizontal screen animation: flip

horizontal screen animation: flip

With alternative page loop

Video:

https://plus.google.com/115366157037831519359/posts/9eUTw8cCCpi

Finally I continued my project, which I started with my last animation bulldoze!

Just too lazy to type it all again, so here’s a link 😉

http://www.pierrox.net/android/applications/lightning_launcher/wiki/doku.php?id=script_animation_flip

Please have a look at it.

Report bugs here.

Feedback welcome!

]]>

Can anyone help me to find a tutorial for scripting in LLX, thanks in advance

Can anyone help me to find a tutorial for scripting in LLX, thanks in advance

]]>

Am having a hard time with scripts, even pre made ones aren’t working.

Am having a hard time with scripts, even pre made ones aren’t working.

I tried using the ‘always there bar’ script ( http://www.pierrox.net/android/applications/lightning_launcher/wiki/doku.php?id=script_always_there_bar) and I keep getting the error ‘can’t get positionY() of null’ what am I doing wrong?

]]>

Change the home page of a desktop (not the home desktop)

Change the home page of a desktop (not the home desktop)

From a previous post, and improving my script with Lukas Morawietz vertical idea.

This is a script that move all the items in a container so the home page change.

Instructions:

– Copy paste this script as a new one, and check ‘appear in lightning menu’

– long click the background of the container you want to change, scripts, run this script.

– input the position of the new home desktop, this can be a bit confusing, I hope the pop-up helps you. You can also scroll to the desired home desktop, it will be detected and shown as default in the inputs.

If the number of cells don’t fit the screen (for example if the cells have a fixed size) you will be warned to exit.

Horizontal pinned items are not moved horizontally. The same with verticals and both.

I didn’t have so much time to test, if you can and you discover a bug please comment here. Thanks.

——————————————

var cont = LL.getEvent().getContainer();

var items=cont.getItems();

var distX=cont.getWidth();

var distY=cont.getHeight();

var cellsFloatX=distX/cont.getCellWidth();

var cellsFloatY=distY/cont.getCellHeight();

var cellsX=Math.round(cellsFloatX);

var cellsY=Math.round(cellsFloatY);

if(Math.abs(cellsFloatX-cellsX)>0.00001)if(!confirm(“Warning, the cells don’t fill the screen as an exact horizontal number.\nDo you want to continue?”))return;

if(Math.abs(cellsFloatY-cellsY)>0.00001)if(!confirm(“Warning, the cells don’t fill the screen as an exact vertical number.\nDo you want to continue?”))return;

var moveX = parseInt(prompt(“Which page do you want to be the home one? (horizontal)(left ones are negative)”,Math.round(cont.getPositionX()/distX))) || 0;

var moveY = parseInt(prompt(“Which page do you want to be the home one? (vertical)(top ones are negative)”,Math.round(cont.getPositionY()/distY))) || 0;

if(moveX==0&&moveY==0)return;

for(var i=items.getLength() – 1;i>=0; — i){

var item=items.getAt(i);

var prop=item.getProperties()

var xx=1;

var yy=1;

var pinmode = prop.getString(“i.pinMode”);

if(pinmode==”X”)xx=0;

else if(pinmode==”Y”)yy=0;

else if(pinmode==”XY”)xx=yy=0;

if(prop.getBoolean(“i.onGrid”)){

var cell=item.getCell();

item.setCell(cell.getLeft() – cellsX * moveX * xx,cell.getTop() – cellsY * moveY * yy,cell.getRight() – cellsX * moveX * xx ,cell.getBottom() – cellsY * moveY * yy);

}else{

item.setPosition(item.getPositionX() – distX * moveX * xx,item.getPositionY() – distY * moveY * yy);

}

}

cont.setPosition(cont.getPositionX() – moveX * distX,cont.getPositionY() – moveY * distY,cont.getPositionScale(),false);

]]>

How to execute a script synchronously?

How to execute a script synchronously?

I read in release notes for 9.9.10 that the script engine is now synchronous.

But still when i.e. called LL.RunScript(“script1”,null); LL.RunScript(“script2”,null); both are executed asynchronous on parallel. How to solve if script2 requires script1 to be finished?

I tried something like setTimeout(new function() { LL.RunScript(“script1”,arg1); },1000); setTimeout(new function() { LL.RunScript(“script2”,arg2); },2000);, but both the anonymous function does not seem to work, the script are executed immediately, not with delay.

function RunScript1() { LL.RunScript(“script1”,null); };setTimeout(Runscript1,1000); does work with delay, but it is not possible to pass arguments.

Any ideas?

]]>

Boing and Save and restore position

Boing and Save and restore position

These are two different scripts, but if you want to use the first you will probably use the second.

Boing

This is a script that will move the item from where this script was launched bouncing around the screen.

You need to run it from an action involving an item. I recommend the swipe of the item (in any direction. The starting direction is totally random)

Save and restore position

This is a script that will save only the position x/y of all the items in a container.

It is saved in the container tag, avoid modify it (the script don’t check if the saved tag is the good one)

Just run it from an item in the container, or from the container itself.

Remember that you need to save the position every time a new item is added to the container. Otherwise that item won’t be restored.

I made the script easy to modify to save different data in case you want to edit it yourself.

—————————— Boing

var bounciness = 0.95;//Reduction every tick, between 0 (only one tick) and 1 (always bouncing) [Recommended 0.95]

var frecuency = 60;//ticks per second [Recommended 60]

var event = LL.getEvent();

var cont = event.getContainer();

var item = event.getItem();

if(item==null){alert(“No item attached to this event”); return;}

var vel = [ (Math.random() – 0.5) * cont.getWidth() , (Math.random() – 0.5) * cont.getHeight() ];

var size = [ item.getWidth() * item.getScaleX() , item.getHeight() * item.getScaleY() ]

tick();

function tick(){

//exit statement

if((Math.abs(vel[0])<1 && Math.abs(vel[1])<1)||LL.isPaused()) return;

//Reduction

vel=[ vel[0] * bounciness , vel[1] * bounciness ];

var newpos = [ item.getPositionX()+vel[0] , item.getPositionY()+vel[1] ];

var t;

//right

t=(newpos[0]+size[0]) – ( cont.getPositionX()+cont.getWidth()/cont.getPositionScale() ) ;

if(t>0){newpos[0]-=2 * t;vel[0]= -vel[0];}

//bottom

t=(newpos[1]+size[1]) – ( cont.getPositionY()+cont.getHeight()/cont.getPositionScale() ) ;

if(t>0){newpos[1]-=2 * t;vel[1]=-vel[1];}

//left

t= newpos[0]- cont.getPositionX();

if(t<0){newpos[0]-=2 * t;vel[0]= -vel[0];}

//top

t= newpos[1] – cont.getPositionY();

if(t<0){newpos[1]-= 2*t;vel[1]= - vel[1];}

//set and repeat

item.setPosition(newpos[0] , newpos[1] );

setTimeout(tick,1000/frecuency);

}

————————-Save and restore position

var velocity = 0.2;//The bigger, the faster (between (0,1] )

var frecuency = 60;//ticks per second [Recommended 60]

var cont = LL.getEvent().getContainer(); //The container

var tag = cont.getTag();

if(tag!=undefined){

//With data, hope it is from this script

var data=JSON.parse(tag);

if(confirm(“Restore?”)){

for(var i=data.ids.length – 1;i>=0; –i){

var item= LL.getItemById(data.ids[i]);

//move the item to their position

if(item!=null) move( item , data.posX[i] , data.posY[i] );

}

cont.setPosition(0,0,1,true);//can be omitted

return;

}

}

if(!confirm(“Save?”))return;

//save process

var data=new Object();

data.ids=[];

data.posX=[];

data.posY=[];

var items = cont.getItems();

for(var i=items.getLength() – 1;i>=0; –i){

//save the data of each item

var t = items.getAt(i);

data.posX[i]=t.getPositionX();

data.posY[i]=t.getPositionY();

data.ids[i]=t.getId();

};

//final save

cont.setTag(JSON.stringify(data));

Android.makeNewToast(“Saved “+data.ids.length+” item’s position”,true).show();

//custom lerp. It moves the item a bit and repeat

function move(item,posx,posy){

var xx=posx-item.getPositionX();

var yy=posy-item.getPositionY();

if( (Math.abs(xx)<1 && Math.abs(yy)<1) || LL.isPaused() ){

item.setPosition(posx,posy);

return;

}

xx *= velocity;

yy *= velocity;

item.setPosition( item.getPositionX()+xx , item.getPositionY()+yy );

setTimeout(function(){move(item,posx,posy);},1000/frecuency);

}

]]>

Do folders have no OnOpen and OnClose event?

Do folders have no OnOpen and OnClose event? Are there other ways to react to? OnOpen can possibly be caught from OnTap of opener, but closing with Back-key not.

]]>

Minimalistic page indicator

Minimalistic page indicator

Talking about indicators, I couldn’t stop thinking how to make a script. There is already one in the wiki, but I wanted one a bit more ‘stock’.

I started thinking complex ways of doing it, but then I realize that simplicity is the best in this case.

So I made one in 34 lines of code, easy to understand (this is an objective adjective, I know) and easy to set up.

Important: due to the custom characters I use, the maximum number of pages is 10. However you can change the character as you wish.

Instructions:

– Copy/paste this script as a new one

– Set it to run in the ‘position change’ event of the desktop

– place an item (recommend: shortcut to ‘do nothing’ and pinned) and label it ‘indicator’.

– [Recommended] Check the snap to pages and uncheck ‘fit desktop to items’ in scrolling options.

It automatically adapts to the desktop, for this reason the home page may not be the number 1.

————————————-

//The special characters

var fill = “➊❷❸❹❺❻❼❽❾❿”;

var empty = “①②③④⑤⑥⑦⑧⑨⑩”;

//Vars

var cont = LL.getEvent().getContainer();

var width=cont.getWidth();

var left = Math.round(cont.getBoundingBox().getLeft()/width);

var right = Math.round(cont.getBoundingBox().getRight()/width)-1;

var page = Math.round(cont.getPositionX()/width);

//With zoom –> no page selected

if(cont.getPositionScale()!=1) page=NaN;

var ind = “”;

var flag=false;

//if more pages, just show “…”

if(right-left+1>empty.length){

right=left+empty.length-1;

flag=true;

}

//indicator

for(var i=0;i<=right-left;++i)ind+=(left+i==page?fill[i]:empty[i]);

if(flag)ind+=”…”;

//apply

try{ item=cont.getItemByLabel(“indicator”).setLabel(ind);

}catch(e){

alert(“Item not found. You need to label an item ‘indicator'”);

}

]]>

Hello, how i change the home desktop with script? thanks

Hello, how i change the home desktop with script? thanks

]]>

Feature request for scripting: it would be great and helpful if events could programmatically be wired.

Feature request for scripting: it would be great and helpful if events could programmatically be wired. Like “OnTap=’ScripyToRun'”.

This would allow to in OnLoad of desktop to set up the event handling.

]]>