Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   New Scripting Engine (GS2) (https://forums.graalonline.com/forums/forumdisplay.php?f=153)
-   -   wraptext (https://forums.graalonline.com/forums/showthread.php?t=68519)

xXziroXx 09-03-2006 03:21 AM

wraptext
 
How can I use wraptext/wraptext2 so that it DOESNT cut words in half when wrapping?

I used this in gs1:

PHP Code:

wraptext 40,,#c; 

.. and it didnt cut the text. However, when I converted it to gs2:

PHP Code:

tokens wraptext(40""player.chat); 

.. it started cutting the text in half.

excaliber7388 09-03-2006 07:06 AM

I'm sorry this post win't help you, but what does wraptext do?

smirt362 09-03-2006 10:26 AM

Quote:

Originally Posted by excaliber7388
I'm sorry this post win't help you, but what does wraptext do?

Instead of this:
Quote:

Ebenezer unexpectedly bagged two tranquil aardvarks with his jiffy vacuum cleaner.
It would be something like this:
Quote:

Ebenezer unexpectedly bagged
two tranquil aardvarks
with his jiffy vacuum cleaner.
It's like typing in Word. If your sentance/word gets too long then it moves part of it to the next line.

excaliber7388 09-03-2006 04:43 PM

Quote:

Originally Posted by smirt362
Instead of this:


It would be something like this:


It's like typing in Word. If your sentance/word gets too long then it moves part of it to the next line.

For what though?
Chat?

xXziroXx 09-03-2006 04:49 PM

Quote:

Originally Posted by excaliber7388
For what though?
Chat?

In this case, yes.

Tolnaftate2004 09-03-2006 05:35 PM

PHP Code:

font "verdana";
style "";
fontsize $pref::graal::defaultfontsize/gettextheight(1,font,style);
tokens wraptext2(40,fontsize," ",font "@" style "@" player.chat); 

This will most accurately split at words and fit into your space. $pref::graal::defaultfontsize is a placeholder for the height in pixels of how tall you want the text to be. Change to your liking.

xXziroXx 09-03-2006 11:19 PM

Quote:

Originally Posted by Tolnaftate2004
PHP Code:

font "verdana";
style "";
fontsize $pref::graal::defaultfontsize/gettextheight(1,font,style);
tokens wraptext2(40,fontsize," ",font "@" style "@" player.chat); 

This will most accurately split at words and fit into your space. $pref::graal::defaultfontsize is a placeholder for the height in pixels of how tall you want the text to be. Change to your liking.

I actually have never used $pref vars untill now.. however, now it doesnt wrap the text at all.

Tolnaftate2004 09-04-2006 05:19 PM

Works for me. If you're using that code, you may want to give the variables a prefix. That could be why it's messing up.

xXziroXx 09-04-2006 05:24 PM

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(1this.fontthis.style); 

  
setTimer(.05);
}

function 
onPlayerEnters() setTimer(.05);

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

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

    
changeimgvis(305 i3);
  }
  
  if (
client.busy == false) {
    if (
keydown2(16,true) || mousex in |player..5player.2.5| && mousey in |player.1player.3|) {
      
hideimgs(300309);
      
ShowNick();
      
ShowHUD();
      for (
04++) changeimgzoom(300 i.7);
    }
  } 

  
setTimer(.05);
}

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

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

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

  
changeimgcolors(3000001);
  
changeimgcolors(3020001);

  
changeimgvis(3013);
  
changeimgvis(3033);
}

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

  
changeimgpart(304003713);
  
changeimgpart(30501424/(player.fullhearts/player.hearts) + 15);

  
changeimgvis(3053);
}
SCRIPTEND 

EDIT: Fixed some values that I changed for testing.

Rapidwolve 09-04-2006 08:49 PM

Quote:

Originally Posted by excaliber7388
I'm sorry this post win't help you, but what does wraptext do?

It wraps text so it looks like a multi-line paragraph

Quote:

Originally Posted by xXziroXx
Im scripting it in a gani

wtf

xXziroXx 09-05-2006 04:52 PM

Quote:

Originally Posted by Rapidwolve
wtf

Yes?

And Tolnaftate2004 (or anyone else), if you can get the gani to work with the wraptext2 that you showed me, Id appriciate it. If not, I will have to make my own wraptext function.

xXziroXx 09-08-2006 05:55 PM

Not anyone who can help?

xXziroXx 10-11-2006 05:26 AM

*bumps* last attempt to get a wraptext expert, otherwise I will make my own function that will wrap the text.

Admins 10-13-2006 01:11 AM

Added some description at http://wiki.graal.net/index.php/Crea...lient#Graal_2D

You must specify the number of pixels (more than 40) and the zoom factor, which should match the zoom factor of the showimg you are using to display the text.


All times are GMT +2. The time now is 01:35 AM.

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