Thread: wraptext
View Single Post
  #9  
Old 09-04-2006, 05:24 PM
xXziroXx xXziroXx is offline
Malorian
xXziroXx's Avatar
Join Date: May 2004
Posts: 5,289
xXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant future
Im scripting it in a gani, so I might aswell post the entire code here since it will be downloaded for everyone.

PHP Code:
GANI0001

SCRIPT
function onCreated()
{
  
this.font = "Verdana";
  
this.style = "";
  
this.fontsize = $pref::graal::defaultfontsize / gettextheight(1, this.font, this.style); 

  
setTimer(.05);
}

function 
onPlayerEnters() setTimer(.05);

function 
onTimeOut()
{
  
hideImgs(300, 309);
  
WordWrap();
  for (
i = 0; i < tokens.size(); i ++) {
    
showtext(300 + i, player.x + 1.6, player.y - 1.4 - 1*((tokens.size() - 1) - i), "Verdana", "cb", tokens[i]);
    
showtext(305 + i, player.x + 1.5, player.y - 1.5 - 1*((tokens.size() - 1) - i), "Verdana", "cb", tokens[i]);
  
    
changeimgcolors(300 + i, 0, 0, 0, 1);

    
changeimgzoom(300 + i, .7);
    
changeimgzoom(305 + i, .7);

    
changeimgvis(305 + i, 3);
  }
  
  if (
client.busy == false) {
    if (
keydown2(16,true) || mousex in |player.x + .5, player.x + 2.5| && mousey in |player.y - 1, player.y + 3|) {
      
hideimgs(300, 309);
      
ShowNick();
      
ShowHUD();
      for (
i = 0; i < 4; i ++) changeimgzoom(300 + i, .7);
    }
  } 

  
setTimer(.05);
}

function 
WordWrap()
{
  
//tokens = wraptext(40, " ", player.chat);
  
tokens = wraptext2(40, this.fontsize, " ", this.font @ "@" @ this.style @ "@" @ player.chat);
  if (
tokens.size() > 5) {
    
this.temp = NULL;
    for (
i = 0; i < 5; i ++) this.temp = this.temp SPC tokens[i];
    
this.text = this.temp.substring(0, this.temp.length() - 2) @ "..";
    
//tokens = wraptext(40, " ", player.chat);
    
tokens = wraptext2(40, this.fontsize, " ", this.font @ "@" @ this.style @ "@" @ player.chat);
  }
}

function 
ShowNick()
{
  
showtext(300, player.x + 1.6, player.y + 3.4, "Verdana", "cb", player.nick.substring(0, player.guild.length() - 3));
  
showtext(301, player.x + 1.5, player.y + 3.3, "Verdana", "cb", player.nick.substring(0, player.guild.length() - 3));

  
showtext(302, player.x + 1.6, player.y + 4.4, "Verdana", "cb", player.guild);
  
showtext(303, player.x + 1.5, player.y + 4.3, "Verdana", "cb", player.guild);

  
changeimgcolors(300, 0, 0, 0, 1);
  
changeimgcolors(302, 0, 0, 0, 1);

  
changeimgvis(301, 3);
  
changeimgvis(303, 3);
}

function 
ShowHUD()
{
  
showimg(304, "ml_gui-hphud.png", player.x + 1.5 - getimgwidth("ml_gui-hphud.png")/16/2, player.y - 1.5 - (19/16)/2);
  
showimg(305, "ml_gui-hphud.png", player.x + 1.5 - getimgwidth("ml_gui-hphud.png")/16/2 + 6/16, player.y - 1.5 - (19/16)/2 + 4/16);

  
changeimgpart(304, 0, 0, 37, 13);
  
changeimgpart(305, 0, 14, 24/(player.fullhearts/player.hearts) + 1, 5);

  
changeimgvis(305, 3);
}
SCRIPTEND 
EDIT: Fixed some values that I changed for testing.
__________________
Follow my work on social media post-Graal:Updated august 2025.
Reply With Quote