Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Show Number Function (https://forums.graalonline.com/forums/showthread.php?t=6657)

LiquidIce00 07-06-2001 07:39 AM

Show Number Function
 
I was bored .. again ;)
and I decided to make a little function to help some people.
I might enhance it if people like it..
it shows any number anywhere on the screen..
the only problem is that the number cant be bigger then 9999999,
else the variable becomes a long and messes up x.x
bare with me since I made this in only like 15 minutes, so it might have some bugs..
oh and I think some1 had one before this .. but I tried and it didnt work well so here is one that works well.

here is the function:
NPC Code:

function LiquidNum() {
//hide if told
if (this.hideprevious=1) {
while (this.previousindex>this.startindex) {
hideimg this.previousindex;
this.previousindex-=1;
}
}
//end hide

//do showimg of the numbers
this.count=0;
while (this.count<strlen(#v(this.number))) {
showimg this.startindex,state.png,this.x,this.y;
//get current number
this.currentnum=strtofloat(#e(this.count,1,#v(this .number)));
//end get current number
changeimgvis this.startindex,4;
changeimgpart this.startindex,this.currentnum*14,81,14,16;
//add to variables
this.startindex+=1;
this.x+=this.space;
this.count+=1;
}
//end showimg

//set highest index if needed
this.previousindex=this.startindex;
//end set highest index
}


now ill explain how to use it.
anywhere in your code you can call it , in a timeout, if player enters. whatever.
Ill explain a if playerenters one ..

NPC Code:

if (playerenters) {
//index in which we should start
this.startindex=200;
//hide previous shown imgs? 1=yes 0=no
//this is usefull if your running it in a timeout and you need it to
//clear previous showimg's so they dont show unwanteds
this.hideprevious=1;
//begin x position
this.x=250;
//y position
this.y=100;
//number to display
this.number=123456;
//space in between numbers
this.space=10;
//run function
LiquidNum();
}



Enjoy ;)
and please tell me if you find any bugs.

oh and i might also include the chars : / so if you need to do dates or something. btw this is extracted out of state.png

kyle0654 07-06-2001 08:00 AM

fun. You could also do:
NPC Code:

function shownumber() {
this.x = 100;
this.y = 250;
this.number = 12345;
showimg 600,@#v(this.number),this.x,this.y;
changeimgvis 600,5;
}


LiquidIce00 07-06-2001 08:02 AM

Quote:

Originally posted by kyle0654
fun. You could also do:
NPC Code:

function shownumber() {
this.x = 100;
this.y = 250;
this.number = 12345;
showimg 600,@#v(this.number),this.x,this.y;
changeimgvis 600,5;
}


yes but its still different
your way uses normal font files my way uses the sprite.png which is prettier.
but still props to u^^

good idea tho I could make it so u can choose which way and also you can change the font and size and all that stuff

kyle0654 07-06-2001 08:14 AM

Actually, I think if you just use arial bold it looks the same. All you need to remember is that the font on sprites.png is made of white arial bold, with blue arial bold underneath, with an offset of (1,1) on the blue text. You could probably use layers 5 and 6 to separate the two...

LiquidIce00 07-06-2001 08:18 AM

Quote:

Originally posted by kyle0654
Actually, I think if you just use arial bold it looks the same. All you need to remember is that the font on sprites.png is made of white arial bold, with blue arial bold underneath, with an offset of (1,1) on the blue text. You could probably use layers 5 and 6 to separate the two...
what if the player has a custom state.png ;\

G_yoshi 07-06-2001 12:50 PM

Quote:

Originally posted by kyle0654
Actually, I think if you just use arial bold it looks the same. All you need to remember is that the font on sprites.png is made of white arial bold, with blue arial bold underneath, with an offset of (1,1) on the blue text. You could probably use layers 5 and 6 to separate the two...
hehe, I learn more about graal everyday :D I has no idea changeimgvis could go past 4.

LiquidIce00 07-07-2001 07:11 AM

erm 2 questions..
any1 want me to update this and make more stuff avaible ?
and also what happens if your using timevar and it becomes a really high number. does that mean you cant make date/time nemore since it becomes a long or what ??


All times are GMT +2. The time now is 01:47 PM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.