script / ondrawscript

O Ilusionista

Captain 100K
What is the difference between when you define a "script" and "ondrawscript" ?
Both runs in every frame, right?

ondrawscript is not listed in any manual or at uTunnels's script reference guide. Where we can lear more about it?
 
I'll have to crack open the code to see what ondrawscript does; my guess is it runs when the entity's sprite is drawn to screen.

The script runs at the start of every update (i.e. engine cycle) for that entity. Usually you want to avoid use of this event, but when applied sparingly it can do some pretty cool things.

DC
 
Hum...but if I need a function which needs to be fired in every update (in every tick, to be more precise), it should be used as script or ondrawscript?

Btw DC, ondrawscript is useful to make a workaround to fix an engine bug (I remember I reported this to uTunnels): the bindentity can lead to bugs. See more from this topic and on, White Dragon had got a solution for it but confirmed that is an engine bug http://www.chronocrash.com/forum/index.php?topic=703.msg10796#msg10796

White Dragon's solution: http://www.chronocrash.com/forum/index.php?topic=703.msg10845#msg10845

It would be great if this could be fixed.

 
O Ilusionista said:
Hum...but if I need a function which needs to be fired in every update (in every tick, to be more precise), it should be used as script or ondrawscript?

This is what Script is for. There is also an updated event, which is the same thing, but fires after all the engine's own code has finished running for that update. Utunnels recommends this, as you are less likely to find yourself fighting with the engine overriding your functions milliseconds after they execute.

DC
 
updatedscriptdata/scripts/newhpbar.c


the above line would not draw anything to screen for me but the below line works just fine.


ondrawscript data/scripts/newhpbar.c
 
Malik, there is no "updatedscript" for entity header. Updated.c runs from the engine, not from an entity header.

For entity header, you can choose from script or ondrawscript. Script is heavier, so use with caution.
But there are times where ondrawscript will have a little delay, like in bind scripts

This is a code I use as SCRIPT (entity header), becasue ONDRAWSCRIPT has 1 tick of delay

Code:
script @script

void main()
{

void self = getlocalvar("self");
void parent = getentityproperty(self, "parent");

    if(parent!=NULL()){
    float x = getentityproperty(parent, "x");
    float z = getentityproperty(parent, "z");
    float a = getentityproperty(parent, "a");
    changeentityproperty(self, "position", x, z+1, 0);
    }
}
@end_script
 
ok thanks but for what i am doing ondraw sees to work just fine i might test on weaker systems like psp
 
Back
Top Bottom