Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting
FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 06-24-2001, 06:20 PM
grim_squeaker_x grim_squeaker_x is offline
Retired Oldbie
grim_squeaker_x's Avatar
Join Date: Mar 2001
Posts: 3,084
grim_squeaker_x will become famous soon enough
Auto Line break making sign NPC

Okay basically this NPC will take a string, tokenize that string and automattically put in line breaks when one line get's too large, here it is:
NPC Code:
// NPC made by Lady Midnight
if (created) {
this.maxlinelength=32;
this.lettersusedonline=0;
setstring test.string,This is just a test of an auto line break making system I hope I can get it to work as it would be pretty cool for editable news and stuff and okay at this point I'm just going to put in some filler don't be surprised if you see strange stuff ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz boring isn't it? Oh well the point of this is to make it as long as possible so I guess that's okay... Some other possible uses could be a guestbook. A place where people can write books in Graal and if you think long and hard about it a real lot of stuff. Anyway this is my biggest string manipulation yet. I think I might put in something for adding line breaks to it <br> or whatever. If you're wondering why there's nearly no puntuation that has to do with the fact that it somehow doesn't accept commas
}
if (playertouchsme) {
setstring player.readingpage,0;
setstring sign.readstring,;
tokenize #s(test.string);
this.lettersusedonline=0;
for (this.i=0;this.i<tokenscount;this.i++) {
this.lettersusedonline+=strlen(#t(this.i))+1;
if (this.lettersusedonline>this.maxlinelength) {
setstring sign.readstring,#s(sign.readstring)" "#t(this.i);
this.lettersusedonline=0+strlen(#t(this.i));
}
else if (this.i==0) setstring sign.readstring,"#t(this.i);
else setstring sign.readstring,#s(sign.readstring) #t(this.i);
}
tokenize #s(sign.readstring);
setstring sign.pages,#v(int((tokenscount-1)/3));
say2 #t(strtofloat(#s(player.readingpage))*3)
#b#t(strtofloat(#s(player.readingpage))*3+1)
#b#t(strtofloat(#s(player.readingpage))*3+2);
}
if (playerendsreading) {
setstring player.readingpage,#v(strtofloat(#s(player.reading page))+1);
if (strtofloat(#s(player.readingpage))<=strtofloat(#s (sign.pages))) {
say2 #t(strtofloat(#s(player.readingpage))*3)
#b#t(strtofloat(#s(player.readingpage))*3+1)
#b#t(strtofloat(#s(player.readingpage))*3+2);
}
}

And believe it or not that whole long string up there get's reworked into a sign without problems.
__________________

Reply With Quote
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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:32 PM.


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