SetTextObj for a custom time counter

O Ilusionista

Captain 100K
I'm trying to make a custom counter, using setTextObj() and I put the code checking the animation frame.
However, for some reason, instead of updating the text object for the duration I specified, it seems to divide between the number of values... which I can't understand.

I've already tried changing the index, I've tried moving it to a function, the result is the same.

C-like:
anim    idle
    loop    0
    delay    200
    offset    32 32
    @script
    int     iIndex  = 0;
    int     iX      = 200;
    int     iY      = 80;
    int     iFont   = 1;
    int     iZ      = 100;
    //int     iTime   = openborvariant("elapsed_time");
    if (frame==1) {int iTime = openborvariant("elapsed_time");settextobj(iIndex, iX, iY, iFont, iZ, "10", iTime+100);}
    if (frame==2) {int iTime = openborvariant("elapsed_time");settextobj(iIndex, iX, iY, iFont, iZ, "09", iTime+100);}
    if (frame==3) {int iTime = openborvariant("elapsed_time");settextobj(iIndex, iX, iY, iFont, iZ, "08", iTime+100);}
    if (frame==4) {int iTime = openborvariant("elapsed_time");settextobj(iIndex, iX, iY, iFont, iZ, "07", iTime+100);}
    if (frame==5) {int iTime = openborvariant("elapsed_time");settextobj(iIndex, iX, iY, iFont, iZ, "06", iTime+100);}
    if (frame==6) {int iTime = openborvariant("elapsed_time");settextobj(iIndex, iX, iY, iFont, iZ, "05", iTime+100);}
    if (frame==7) {int iTime = openborvariant("elapsed_time");settextobj(iIndex, iX, iY, iFont, iZ, "04", iTime+100);}
    if (frame==8) {int iTime = openborvariant("elapsed_time");settextobj(iIndex, iX, iY, iFont, iZ, "03", iTime+100);}
    if (frame==9) {int iTime = openborvariant("elapsed_time");settextobj(iIndex, iX, iY, iFont, iZ, "02", iTime+100);}
    if (frame==10){int iTime = openborvariant("elapsed_time");settextobj(iIndex, iX, iY, iFont, iZ, "01", iTime+100);}
    @end_script  
    frame    data/chars/empty.gif
    frame    data/chars/empty.gif
    frame    data/chars/empty.gif
    frame    data/chars/empty.gif
    frame    data/chars/empty.gif
    frame    data/chars/empty.gif
    frame    data/chars/empty.gif
    frame    data/chars/empty.gif
    frame    data/chars/empty.gif
    frame    data/chars/empty.gif
    frame    data/chars/empty.gif
    @cmd    killentity getlocalvar("self")
    frame    data/chars/empty.gif

See the result in the video

EDIT: I've discovered the issue - looks like the word "timecounter" is a reserved word and can't be used as an entity name.
Once I rename it to "customcounter", the code works...
 
Last edited:
Hii, hmm what about of a variable which it's showed by the text obj it could be minus in a specific frame of the object, when variable reaches 0 will perform the action. I did it in Fire Hearts in a escape part because I wanted to trigger a scene when time out and player couldn't escape
 
Hii, hmm what about of a variable which it's showed by the text obj it could be minus in a specific frame of the object, when variable reaches 0 will perform the action. I did it in Fire Hearts in a escape part because I wanted to trigger a scene when time out and player couldn't escape
That is exactly what I am building :)
This custom counter will be used on bonus stages to many things, like removing the players control, play music, etc
 
Back
Top Bottom