key scripts & images

msmalik681

OpenBOR Developer
Staff member
i have 2 quick questions:

first about key scripts can they be used on the player select screen ?

second does anyone have a script that will let you show any image file on screen ? (relative to screen not player or stage) something like settextobj would be great !

I am trying to load a single image and display it on screen i have tried a code but its not working for me can anyone help ?

@script
void test = loadsprite("data/chars/0gamefx/darken.png");
{
drawsprite(test,0,0,99999999);
}
@end_script

with this code i am not getting anything displaying on screen !
 
i think i have figured out how to load a sprite but can someone just let me know this

void test = loadsprite("data/chars/0gamefx/darken.png");

will the above code give my image "darken.png" the handle "test"
 
malik4ever said:
will the above code give my image "darken.png" the handle "test"

No. Sprites are kept in a dynamic table managed by the engine; you cannot set what handle they are given. Loadsprite() returns the newly loaded sprite's handle on success; you will of course need it if you want to do anything script related with the sprite.

As for variable assignment, OpenBOR's script engine is based on and behaves like C. As written, your code will create a variable test and assign its value to the handle of your newly loaded sprite, not the other way around.

DC
 
I'm no scripter, but this is the way I know how to do it, sprites are loaded in level.c

void main()
{

setglobalvar("spritename", loadsprite("data/chars/0gamefx/darken.png"));

}

Then use this to call it -
drawsprite(getglobalvar("spritename"), 0, 0, 99999999, 0);


Hope this helps some.

 
@script
{
setglobalvar("dark",loadsprite("data/chars/0gamefx/darken.png"));
}
{
drawsprite("dark",300,200,0,1);
}
@end_script


the above script still getting below error:

Function requires a valid sprite handle 3 integer values, 5th integer value is optional: drawsprite(sprite, int x, int y, int z, int sortid)
Script function 'drawsprite' returned an exception, check the manual for details.

OpCode: 8

but i did notice this

Warning: 1 script variants are not freed, dumping...
openbor_loadsprite

this makes me think the sprite did load
 
check my post again, you're missing part of the code -

drawsprite(getglobalvar("spritename"), 0, 0, 99999999, 0);

you had
drawsprite("dark",300,200,0,1);

you need
drawsprite(getglobalvar("dark"),300,200,0,1);
 
writing the code like that wont cause a crash but the image is till not displaying on screen.

The main reason I wanted to do this is so all my speech images don't have to share one palette and I could display multiple images at one was even thinking of using it to make full screen animations did not know it would be this complicated guess I have to find a work around thanks anyway BeasTie
 
It's probably working, but it's probably displaying the image for only a split second. You need to tell it how long it should display or it will only last one game tick.  I never found out how to do this, I'm using update script that runs every game tick.
 
Man sorry I just re-read this. 

You can do what you want by just using 'palette none' for the text entities.

Code:
~If path is set to none, alternate palettes are ignored and allows each frame (see 'frame' in animation data below) to use its own palette
~Useful to create effect libraries without having to design public palette for all of those effects

 
msmalik681 use drawsprite() method in a "ondrawscript" event and not in a animation event.
drawsprite() draws a sprite for 1 frame ONLY!
so you have to draw a sprite every frame in the main of a ondrawscript event for example.
If you use drawsprite() in an animation it will not work ;)
 
Back
Top Bottom