Graal Forums  

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

Reply
 
Thread Tools Search this Thread Display Modes
  #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 is on a distinguished road
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
  #2  
Old 06-24-2001, 08:03 PM
Solareon Solareon is offline
Registered User
Solareon's Avatar
Join Date: Jun 2001
Location: In a corn field
Posts: 548
Solareon is on a distinguished road
Send a message via AIM to Solareon
Question

About how long does it take to parse the information?
as in the delay between the event and the sign
__________________
-Solareon Doll, thanks to BirdBird_0 for making it
-
First person to choke on a gummi bear and cough it up =)

AIM: SolareonX
flame me 24/7 roffel
-- l33t
JubieSaotomeX < Me
Reply With Quote
  #3  
Old 06-24-2001, 09:10 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 is on a distinguished road
Re: Question

Quote:
Originally posted by Solareon
About how long does it take to parse the information?
as in the delay between the event and the sign
Optimally it's instantaneous (sp?), but there might be up to one second's delay between display. All depends on CPU speed.
__________________

Reply With Quote
  #4  
Old 06-24-2001, 10:02 PM
kyle0654 kyle0654 is offline
-. .`
kyle0654's Avatar
Join Date: Mar 2001
Posts: 1,000
kyle0654 is on a distinguished road
nice. Though it could mess up with playerendsreading on some things. Optimally you'd build a sign from the ground up...but that takes some doing, and you'd have to use ascii codes (trust me, you can do it with a letter set string-array, but it'll give all caps since strequals isn't case sensitive) but nice job anyway
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 01:17 PM.


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