Die_In_Fire
Well-known member
Cannot get it to work either...
this is what I have:
ad this is the error I get: OpenBoR v3.0 Build 3984
this is what I have:
Code:
name texto1
type none
health 1
gfxshadow 0
nomove 1 0
facing 1
nolife 1
offscreenkill 7000
ondrawscript @script
// Per fare un testo dove continuano le animazioni utilizzare noaiflag?
void main() {
void self = getlocalvar("self");
int animpos = getentityproperty(self, "animpos");
int vres = openborvariant("vresolution");
int hres = openborvariant("hresolution");
int time = openborvariant("elapsed_time");
int i = 0;
char text = array(0);
int y = 180, vspace = 15, font_index = 0;
int transp = 100;
set(text, i++, "\" line1 \"");
set(text, i++, "\" line2 \"");
changedrawmethod(NULL(), "enabled", 1);
changedrawmethod(NULL(), "reset", 1);
//changedrawmethod(NULL(), "flag", 1);
changedrawmethod(NULL(), "alpha", 6);
changedrawmethod(NULL(), "channelg", transp);
changedrawmethod(NULL(), "channelr", transp);
changedrawmethod(NULL(), "channelb", transp);
drawbox (0, 170 , hres, 50, 5000, rgbcolor(0x00,0x00,0x00), 6);
changedrawmethod(NULL(), "enabled", 0);
changedrawmethod(NULL(), "reset", 1);
if ( getlocalvar("step") == NULL() ) setlocalvar("step", 0);
for ( i = 0; i < size(text); ++i ) {
char line = get(text,i);
int step = getlocalvar("step");
if ( i > step ) continue;
if ( i >= 0 ) y += vspace*i;
if ( i == step ) {
if ( draw_anim_string(hres/2-strwidth(line, 0)/2, y, font_index, line, 10, 0) >= strlength(line) ) {
if ( step < size(text) ) setlocalvar("step", step+1);
clear_draw_anim_string();
}
} else {
int next_time = time+get_next_time(openborvariant("game_speed")*2);
if ( getlocalvar("wait") == NULL() ) setlocalvar("wait", next_time);
drawstring(hres/2-strwidth(line, 0)/2, y,font_index,line);
}
}
if ( getlocalvar("wait") != NULL() && getlocalvar("wait") < time ) killentity(self);
if (animpos > 0) if ( key("attack") || key("jump") || key("esc") ) killentity(self);
setidle_after_spawn();
}
int draw_anim_string(int x, int y, int font_index, char str, int refresh_time, int loop_flag, int sound) {
int time = openborvariant("elapsed_time");
char temp_str = "";
if ( getlocalvar("timing") == NULL() ) setlocalvar("timing", time+refresh_time);
if ( getlocalvar("cursor") == NULL() ) setlocalvar("cursor", 0);
if ( getlocalvar("prev_char") == getchar(str, getlocalvar("cursor")) && getlocalvar("prev_char") == " " ) setlocalvar("timing",time-1); // non contiamo gli spazi consecutivi
if ( getlocalvar("timing") < time ) {
if (sound != NULL() && getlocalvar("cursor") < strlength(str) && getchar(str, getlocalvar("cursor")) != " " ) playsample(sound);
setlocalvar("prev_char",getchar(str, getlocalvar("cursor")));
setlocalvar("cursor", getlocalvar("cursor")+1);
setlocalvar("timing", NULL());
if ( loop_flag == 1 ) {
if ( getlocalvar("cursor") > strlength(str) ) setlocalvar("cursor", 0); // Oppure 1 se si vuole ricominciare dalla prima lettera
} else {
if ( getlocalvar("cursor") > strlength(str) ) setlocalvar("cursor", strlength(str));
}
}
temp_str = strleft(str, getlocalvar("cursor"));
drawstring(x,y,font_index,temp_str);
return strlength(temp_str);
}
int setidle_after_spawn() {
int i;
for (i = 0; i < openborvariant("count_entities"); ++i) {
void ent = getentity(i);
if ( getentityproperty(ent, "exists") ) {
if ( getentityproperty(ent, "type") == openborconstant("TYPE_ENEMY") ) {
int anim_id = getentityproperty(ent, "animationid");
if ( anim_id != openborconstant("ANI_SPAWN") && anim_id != openborconstant("ANI_RESPAWN") && anim_id != openborconstant("ANI_IDLE") ) changeentityproperty(ent, "animation", openborconstant("ANI_IDLE"));
}
} // fine if exists
} // fine for
}
int key(char k) {
int i;
for(i = 0; i < openborvariant("maxplayers"); i++) {
if(playerkeys(i, 1, k)) {
return 1;
}
}
return 0;
}
void ondestroy() {
int i;
for (i = 0; i < openborconstant("MAX_ENTS"); ++i) {
void ent = getentity(i);
if ( getentityproperty(ent, "exists") ) {
int anim_id = getentityproperty(ent, "animationid");
if ( getentityproperty(ent, "type") == openborconstant("TYPE_PLAYER")
|| getentityproperty(ent, "type") == openborconstant("TYPE_ENEMY") ) {
if ( getentityproperty(ent, "type") == openborconstant("TYPE_ENEMY") ) {
if ( anim_id != openborconstant("ANI_SPAWN") && anim_id != openborconstant("ANI_RESPAWN") ) {
setidle(ent, openborconstant("ANI_IDLE"), 1);
}
}
changeentityproperty(ent, "noaicontrol", 0);
changeopenborvariant("nojoin", 0);
}
} // fine if exists
} // fine for
}
@end_script
onspawnscript @script
void main() {
int i;
for (i = 0; i < openborconstant("MAX_ENTS"); ++i) {
void ent = getentity(i);
if ( getentityproperty(ent, "exists") ) {
int anim_id = getentityproperty(ent, "animationid");
if ( getentityproperty(ent, "type") == openborconstant("TYPE_PLAYER")
|| getentityproperty(ent, "type") == openborconstant("TYPE_ENEMY") ) {
float base = getentityproperty(ent, "base");
changeentityproperty(ent, "noaicontrol", 1);
changeentityproperty(ent, "aiflag", "running", 0);
changeentityproperty(ent, "aiflag", "jumping", 0);
if ( getentityproperty(ent, "type") == openborconstant("TYPE_PLAYER") ) {
if ( anim_id != openborconstant("ANI_SPAWN") && anim_id != openborconstant("ANI_RESPAWN") ) {
setidle(ent,openborconstant("ANI_IDLE"),1);
}
}
changeentityproperty(ent, "position", NULL(), NULL(), base);
changeentityproperty(ent, "velocity", 0,0,0);
changeopenborvariant("nojoin", 1);
}
} // fine if exists
} // fine for
}
@end_script
anim idle
loop 1 1 2
bbox 0
delay 100
offset 0 0
frame none
frame none
frame none
ad this is the error I get: OpenBoR v3.0 Build 3984
Code:
Script compile error: can't find function 'clear_draw_anim_string'
Script compile error in 'ondrawscript': clear_draw_anim_string line 41, column 28
Can't compile script 'ondrawscript' data/levels/dd1/texto1.txt