Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting > New Scripting Engine (GS2)
FAQ Members List Calendar Today's Posts

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 09-03-2006, 03:21 AM
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
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.
__________________
Follow my work on social media post-Graal:Updated august 2025.

Last edited by xXziroXx; 09-03-2006 at 04:50 PM..
Reply With Quote
  #2  
Old 09-03-2006, 07:06 AM
excaliber7388 excaliber7388 is offline
Banned
excaliber7388's Avatar
Join Date: Jul 2005
Location: US
Posts: 5,229
excaliber7388 can only hope to improve
Send a message via AIM to excaliber7388
I'm sorry this post win't help you, but what does wraptext do?
Reply With Quote
  #3  
Old 09-03-2006, 10:26 AM
smirt362 smirt362 is offline
Tee Hee
smirt362's Avatar
Join Date: Feb 2005
Location: Texas
Posts: 2,101
smirt362 has a brilliant futuresmirt362 has a brilliant futuresmirt362 has a brilliant futuresmirt362 has a brilliant futuresmirt362 has a brilliant futuresmirt362 has a brilliant futuresmirt362 has a brilliant future
Send a message via AIM to smirt362 Send a message via MSN to smirt362
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.
__________________

Don Hertzfeldt <3
Reply With Quote
  #4  
Old 09-03-2006, 04:43 PM
excaliber7388 excaliber7388 is offline
Banned
excaliber7388's Avatar
Join Date: Jul 2005
Location: US
Posts: 5,229
excaliber7388 can only hope to improve
Send a message via AIM to excaliber7388
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?
Reply With Quote
  #5  
Old 09-03-2006, 04:49 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
Quote:
Originally Posted by excaliber7388
For what though?
Chat?
In this case, yes.
__________________
Follow my work on social media post-Graal:Updated august 2025.
Reply With Quote
  #6  
Old 09-03-2006, 05:35 PM
Tolnaftate2004 Tolnaftate2004 is offline
penguin.
Join Date: Jul 2004
Location: Berkeley, CA
Posts: 534
Tolnaftate2004 is a jewel in the roughTolnaftate2004 is a jewel in the rough
Send a message via AIM to 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.
__________________
◕‿‿◕ · pfa · check yer syntax! · src

Killa Be: when i got that locker in 6th grade the only thing in it was a picture of a midget useing a firehose :/
Reply With Quote
  #7  
Old 09-03-2006, 11:19 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
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.
__________________
Follow my work on social media post-Graal:Updated august 2025.
Reply With Quote
  #8  
Old 09-04-2006, 05:19 PM
Tolnaftate2004 Tolnaftate2004 is offline
penguin.
Join Date: Jul 2004
Location: Berkeley, CA
Posts: 534
Tolnaftate2004 is a jewel in the roughTolnaftate2004 is a jewel in the rough
Send a message via AIM to Tolnaftate2004
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.
__________________
◕‿‿◕ · pfa · check yer syntax! · src

Killa Be: when i got that locker in 6th grade the only thing in it was a picture of a midget useing a firehose :/
Reply With Quote
  #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(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.
__________________
Follow my work on social media post-Graal:Updated august 2025.
Reply With Quote
  #10  
Old 09-04-2006, 08:49 PM
Rapidwolve Rapidwolve is offline
Registered User
Join Date: Jul 2006
Posts: 1,241
Rapidwolve is an unknown quantity at this point
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
Reply With Quote
  #11  
Old 09-05-2006, 04:52 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
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.
__________________
Follow my work on social media post-Graal:Updated august 2025.
Reply With Quote
  #12  
Old 09-08-2006, 05:55 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
Not anyone who can help?
__________________
Follow my work on social media post-Graal:Updated august 2025.
Reply With Quote
  #13  
Old 10-11-2006, 05:26 AM
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
*bumps* last attempt to get a wraptext expert, otherwise I will make my own function that will wrap the text.
__________________
Follow my work on social media post-Graal:Updated august 2025.
Reply With Quote
  #14  
Old 10-13-2006, 01:11 AM
Admins Admins is offline
Graal Administration
Join Date: Jan 2000
Location: Admins
Posts: 11,693
Admins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud of
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.
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 05:11 PM.


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