This one is most probably ‘a bug’.

This one is most probably ‘a bug’.

I have below Script to be run on resumed event for a text item to make it as a countdown bar.

It runs fine most of the time when I press Back to exit current app/activity and go to home screen. However, if I press the home button, an error is occurred.

var npt = LL.getVariables().getInteger(‘varNextPrayerTime’);

var mnpt = LL.getVariables().getFloat(‘varMintoNPT’);

var mtp = Math.round((((npt – Math.floor(Date.now() / 1000)) / 60) / mnpt) * 710);

if (mtp >= 0) {

var e=LL.getEvent();

var c=e.getContainer();

var item = c.getItemByName(‘barPrayer’);

item.setSize(mtp,17);

Android.makeNewToast(mtp, true).show();

}

]]>

10 Commentsto This one is most probably ‘a bug’.

  1. Anonymous says:

    < ![CDATA[

    This also happened if my phone is locked. Also happening whenever I interact with other items.

    ]]>

  2. Anonymous says:

    < ![CDATA[

    Where is the script set? In the resumed event of the item or of the container?

    ]]>

  3. Anonymous says:

    < ![CDATA[

    seems LL.getEvent().getContainer() returns null

    ]]>

  4. Anonymous says:

    < ![CDATA[

    TrianguloY​ of the item.

    ]]>

  5. Anonymous says:

    < ![CDATA[

    I recommend then to simply use LL.getEvent().getItem()


    Or set it in the resumed event of the container with the item.



    When a script is run in the resumed event of an item, LL.getEvent().getContainer() normally returns null, other times an undefined container.

    ]]>

  6. Anonymous says:

    < ![CDATA[

    TrianguloY I did this, still getting error. I will put the resumed on container



    var npt = LL.getVariables().getInteger(‘varNextPrayerTime’);



    var mnpt = LL.getVariables().getFloat(‘varMintoNPT’);



    var mtp = Math.round((((npt – Math.floor(Date.now() / 1000)) / 60) / mnpt) * 665);



    if (mtp < 0) {var mtp = 0;}




    var e=LL.getEvent().getItem();


    var item = e.getItemByName(‘barPrayer’);


    item.setSize(mtp,17);

    ]]>

  7. Anonymous says:

    < ![CDATA[

    No no.


    LL.getEvent().getItem() returns the item where the script is run, so simply


    var item=LL.getEvent().getItem()

    ]]>

  8. Anonymous says:

    < ![CDATA[

    You mean the code should be this way? It is not working and gives new error. Cannot find function setSize in object function getItem()



    var npt = LL.getVariables().getInteger(‘varNextPrayerTime’);



    var mnpt = LL.getVariables().getFloat(‘varMintoNPT’);



    var mtp = Math.round((((npt – Math.floor(Date.now() / 1000)) / 60) / mnpt) * 665);



    if (mtp < 0) {var mtp = 0;}



    var item=LL.getEvent().getItem;



    item.setSize(mtp,17);

    ]]>

  9. Anonymous says:

    < ![CDATA[

    You forgot the () in the getItem

    ]]>

  10. Anonymous says:

    < ![CDATA[

    Grrrrrrrr. Thanks TrianguloY​



    The good part of this discussion that I learnt new thing of getItem() function. That it will always gets the item which is running the script.



    Love LL

    ]]>

Leave a Reply

Your email address will not be published. Required fields are marked *