Graal Forums  

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

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 04-04-2012, 09:34 PM
callimuc callimuc is offline
callimuc's Avatar
Join Date: Nov 2010
Location: Germany
Posts: 1,015
callimuc is a splendid one to beholdcallimuc is a splendid one to beholdcallimuc is a splendid one to beholdcallimuc is a splendid one to beholdcallimuc is a splendid one to behold
Sign messages

Hey guys,

today I made something similar like the say2() command for Shaded Legend. Itīs nothing special and I didnīt spend that much time on this. Basicly I first of wanted to try having it look like on Atlantis but for now this was ok aswell for me . If you use it you might want to change some things (as example the layout).



How you can change the layout:
  • You can change the background image by changing the layout_imageīs filename. The width of the GUI is related to the images width so make sure your image got the correct size.
  • You can change the backgrounds alpha by changing the layout_alpha
  • How fast the text will appear can be setted with the text_speed
  • The text below the GUI can be changed by editing text_a and text_s
  • In line 45 you can change the fontcolor.
  • I attached the background image I used for this. Feel free to use it.

It is right this part
PHP Code:
const layout_image "callimuc_say3background.png";
const 
layout_alpha 0.8;
const 
text_speed   0.1;
const 
text_a       "A - Close";
const 
text_s       "S - Scroll to bottom"
and
PHP Code:
profile.fontcolor = {
  
61,23,0,225
}; 



How you can use this:

This is just a really simple example:
  1. Create a class called function_say3
  2. Put this into the NPC you want to use this on. Just touch it than
    PHP Code:
    //#CLIENTSIDE
    function onCreated() {
      
    this.join("function_say3");
    }

    function 
    onPlayerTouchsMe() {
      
    this.say3("Hello this is your new sign!");

  3. For weapons you could use this and just fire the weapon than
    PHP Code:
    //#CLIENTSIDE
    function onCreated() {
      
    this.join("function_say3");
    }

    function 
    onWeaponFired() {
      
    this.say3("Hello this is your new message!");


Here you can find the script:
http://pastebin.graalcenter.org/read...d=102062213349

For those of you using a custom movement keep that there is enabledefmovement (line 101) and disabledefmovement (line 17) used. You should fit that with your movement than.


Well I donīt think there is that much more to say. If you have any suggestions or if there is anything bugged feel free to tell me.
Attached Thumbnails
Click image for larger version

Name:	callimuc_say3background.png
Views:	239
Size:	2.2 KB
ID:	54482  
__________________
MEEP!
Reply With Quote
  #2  
Old 04-04-2012, 09:54 PM
DustyPorViva DustyPorViva is offline
Will work for food. Maybe
DustyPorViva's Avatar
Join Date: Sep 2003
Location: Maryland, USA
Posts: 9,589
DustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond repute
Send a message via AIM to DustyPorViva Send a message via MSN to DustyPorViva
You know I released my version of an upgraded say2 system with scrolling and input and everything, right?
Reply With Quote
  #3  
Old 04-04-2012, 09:56 PM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
Constants should typically be in ALL_CAPITALS.
__________________
Reply With Quote
  #4  
Old 04-04-2012, 10:06 PM
callimuc callimuc is offline
callimuc's Avatar
Join Date: Nov 2010
Location: Germany
Posts: 1,015
callimuc is a splendid one to beholdcallimuc is a splendid one to beholdcallimuc is a splendid one to beholdcallimuc is a splendid one to beholdcallimuc is a splendid one to behold
Quote:
Originally Posted by DustyPorViva View Post
You know I released my version of an upgraded say2 system with scrolling and input and everything, right?
Now where you said that I remember that you released it with your project

Quote:
Originally Posted by cbk1994 View Post
Constants should typically be in ALL_CAPITALS.
oh ok thanks. Ill note that one
__________________
MEEP!
Reply With Quote
  #5  
Old 04-05-2012, 03:00 PM
Emera Emera is offline
Delterian Hybrid
Emera's Avatar
Join Date: Mar 2011
Location: Newcastle Upon-Tyne
Posts: 1,704
Emera is a jewel in the roughEmera is a jewel in the rough
Not bad :P Good work!
__________________
Reply With Quote
  #6  
Old 04-06-2012, 07:53 AM
Mark Sir Link Mark Sir Link is offline
Kevin Azite
Mark Sir Link's Avatar
Join Date: Sep 2005
Posts: 1,489
Mark Sir Link is just really niceMark Sir Link is just really nice
Send a message via AIM to Mark Sir Link
you should probably reserve functions with on prefixed for actual events that are being thrown.

also rather than constantly creating the UI each time you want to use it, create the UI controls the first time and hide/show as necessary.
Reply With Quote
  #7  
Old 04-25-2012, 07:39 AM
Devil_Lord2 Devil_Lord2 is offline
David K?
Devil_Lord2's Avatar
Join Date: Apr 2011
Location: PA, MD.
Posts: 643
Devil_Lord2 can only hope to improve
Dusty I am fixing this up a bit, probably not efficiently though.. I wanted to reread this statement to see if anyone has said anything helpful and so far not really.

Do you mind linking me to yours?

Currently what I've fixed on this is hiding and showing and not destroying.
The problem where you had to click the screen to actually press a button.
I've made it so you set the speed externally depending on who or what is saying it (I should add in if it is a person or sign)
I have made it so it can speed up the process by pressing right a few times each time making it go faster.
At the end of the page if you press right it ends the page (this means you need to use say3A and say3B, B for when there is another page).
I need to add it to finish the page when down is pressed and to go back a page when left is pressed.

Possibly add in head images if that is possible, and each page will have to be put in externally while using a timeout. This will allow there to be use of GUI buttons if there might be a yes or no question or whatever...

Dusty please get back to me? Yours could be more efficient to work with since I'm not a great programmer and still claim the basics at the least, as I always will since there is always much to learn. :]


PHP Code:
NPC 24 21
//#CLIENTSIDE
function onPlayerEnters(){
  
this.join("functions_say3");
  
this.say3B("
Text stuff here.
"
,.1);
  
onTimeout();
}

function 
onTimeout(){
  if (
this.textStop == && this.read == 1){
   
this.say3B(" Oh I see... Well I will get right on that",.11);
  }
  
settimer(.05);
}
NPCEND 
Each page finished this.read++;
.1 and .11 is the text speed, which subtracts by .02 each time the right key is pressed.
__________________

Digital Media Artist - David K? </3 (UnLoved)
www.davidkrout.com
www.twitch.com/DavidKkz



Reply With Quote
  #8  
Old 04-26-2012, 02:50 AM
Devil_Lord2 Devil_Lord2 is offline
David K?
Devil_Lord2's Avatar
Join Date: Apr 2011
Location: PA, MD.
Posts: 643
Devil_Lord2 can only hope to improve
So, I've edited the program Callimuc created, had a few ... differences in expectations of the script so I just wanted to post it like it was open-source.

PHP Code:
const layout_image "callimuc_say3background.png";
const 
layout_alpha 0.8;
const 
TEXT_A   "A - Close";
const 
TEXT_N   "Right Arrow to go to the next page.";
const 
TEXT_S   "Left and Right arrow to change scroll speed."

How you can use this:

  1. Create a class called say3
  2. Put this into the NPC you want to use this on. Just touch it than
    PHP Code:
    //#CLIENTSIDE
    function onCreated() {
      
    this.join("say3");
    }

    function 
    onPlayerTouchsMe() {
      
    this.say3("Hello this is your new sign!");

  3. For weapons you could use this and just fire the weapon than
    PHP Code:
    //#CLIENTSIDE
    function onCreated() {
      
    this.join("function_say3");
    }

    function 
    onPlayerEnters() {
    this.read 0;
      
    this.say3(0,.11,"sleep","
    Good evening young one.

    You've been in a coma for the 
    past two weeks. 

    Someone has also been looking for 
    a person named"
    SPC tok[0SPC tok[1]@".


    Are you this person?


    "
    );
      
    onTimeout();
    }

    function 
    onTimeout(){
      if (
    this.textStop == && this.read == 1){
      
    temp.tok player.nick.tokenize();
      
    this.say3(0,.1,"idle""comment sentences here");
      
    settimer(.05);


params[0]
0 is the main messages, 1 is the ending message that says press A.

params[1]
This is the sleep time per letter in the message.
When it comes to a period it stops for the sleeptime +.15
An older NPC might have a slower speak time...
Players can hold down left or right to slow down or speed up the text.
Also players can press down to skip to the end.

params[2]
Place your gani name in quotes which you want to be set on each message.
Idle might be what you want it to set, for mine it starts in bed.

params[3]
List your comment here.

Here you can find the new script:
http://pastebin.graalcenter.org/read...86866510101046


When you enter into the reading part it tells the script that you are reading with this.textStop = 1;
If you aren't reading the next message will come up after the timeout.
(I have yes or no buttons pop up to activate the next say3)

Also, each time a message is finished this.read adds by 1.

For my buttons I had the buttons pop up on 1 (starts on 0), and then do ++ so it stops everything on 2, and when a button is clicked it goes to 3, when the next say3 happens.



For the future:
As you can see I tried to have the message repeat when the up button was pressed... I had it working once but I broke it and gave up.

Also I'd like to make the external side, the actual npc be able to go back to previous messages.

Possibly have an easier way to have heads and directions show.

Additions:
Constants are capitalized - Thanks cbk.

The new script works without having to click the GUI to use the buttons, I feel it is redundant and shouldn't need to do that.

It is a great way to loop through say3s.

Cons: The button that I have is outside of the class, and the timeout that calls the different say3's are outside of the class. (But I suppose that is how it should be.)

Please let me know if there is anyway we could improve on his program.
I couldn't find Dustys script anywhere. I don't think one should come into a thread, mention they have done it but not show where, and I have searched.
Thank you Callimuc.


-edit-
I broke the down key for the ending say3's, that will have to be edited later.
__________________

Digital Media Artist - David K? </3 (UnLoved)
www.davidkrout.com
www.twitch.com/DavidKkz




Last edited by Devil_Lord2; 04-26-2012 at 03:05 AM..
Reply With Quote
  #9  
Old 04-26-2012, 03:11 AM
DustyPorViva DustyPorViva is offline
Will work for food. Maybe
DustyPorViva's Avatar
Join Date: Sep 2003
Location: Maryland, USA
Posts: 9,589
DustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond repute
Send a message via AIM to DustyPorViva Send a message via MSN to DustyPorViva
Quote:
Originally Posted by Devil_Lord2 View Post
Dusty I am fixing this up a bit, probably not efficiently though.. I wanted to reread this statement to see if anyone has said anything helpful and so far not really.

Do you mind linking me to yours?
http://forums.graalonline.com/forums...hp?t=134259069
Reply With Quote
  #10  
Old 04-26-2012, 05:44 PM
Devil_Lord2 Devil_Lord2 is offline
David K?
Devil_Lord2's Avatar
Join Date: Apr 2011
Location: PA, MD.
Posts: 643
Devil_Lord2 can only hope to improve
Ah I see... I'm not sure I would take your sign over this one, however I am interested in the chickens.. is it alright if I use the chicken images?
Actually I'm not sure, I can understand why you wouldn't want the whole sign to 'move on' without you per se...
But his I feel has a nice animated touch... so I don't know..

Also modify the old line with this:

PHP Code:
    this.punctuations = {'.','!','?',';',':'};
    for (
this.newText 0this.newText message.length(); this.newText ++) { 
      
say3_text.text "<font size = 20><b>" message.substring(0this.newText) @ "</b></font>";
      
say3_scroll.scrollToBottom();
      if (
message.substring(this.newText-11in this.punctuations){
        
sleep(this.ts 1);
      }
      else{
        
sleep(this.ts);
      }
      if (
skippage){
        break;
      }
    } 
I've fixed it so it does stop right AFTER the punctuation instead of before it lol... It also checks for other punctuation marks for after sentence pauses.
I've also made it show the window on the second messages so it doesn't 'take over control'.

I'll post the finished results when I'm done. I still would like to have it go back to separate old messages but that wouldn't be part of the class I don't think...
Unless it can save previous ones... I don't know. It would require some technical thinking that I'm not ready to give yet.

I'm wondering if I should reposition the join say3 part, so you can do the message first, and if you leave everything else null it will take the defaults...
(I've finished this, message comes first, then gani, then text_speed, then if it is a continuing message or not. So you could just do say3("message"); and leave it at that should you want to. Defaults are idle gani, .1 text speed, and ending sign. Once again I'll repost when it is finished.)




Problems noticed:
Currently having a problem with using it on another level, I don't think index 203 or 204 is used, however they aren't showing. I think this could easily be fixed by just making it a GUI instead of images.
__________________

Digital Media Artist - David K? </3 (UnLoved)
www.davidkrout.com
www.twitch.com/DavidKkz




Last edited by Devil_Lord2; 04-26-2012 at 06:54 PM..
Reply With Quote
  #11  
Old 05-21-2012, 04:40 AM
Devil_Lord2 Devil_Lord2 is offline
David K?
Devil_Lord2's Avatar
Join Date: Apr 2011
Location: PA, MD.
Posts: 643
Devil_Lord2 can only hope to improve
Same as last time...

Instead of with image, so it works in other say3's (Maybe I did something wrong) and I find it easier to work with, I've made them gui texts.

Also, if you have ..., it won't pause for time+1 after each dot, it will now do the three dots the pause.

Somehow I'd like to add a going back button, and I'd like to show the scroll speed that will be visually appealing still.

PHP Code:
// Scripted by *callimuc
// Edited by David K?
//#CLIENTSIDE
const layout_image "callimuc_say3background.png";
const 
layout_alpha 0.8;
const 
TEXT_A   "A - Close";
const 
TEXT_N   "Right Arrow to go to the next page.";
const 
TEXT_S   "Left and Right arrow to change scroll speed.";

function 
onCreated() {
  
say3_mainwindow.destroy();
  
say3(message);
  
hideimgs(203204);
  
this.textStop 0;
  
this.read     0;
}

function 
say3(message,gani,text_speed,end) {
  if (
gani == null){
    
gani "idle";
  }
  if (
text_speed == null){
    
text_speed .1;
  }
  
//player.chat = end SPC text_speed SPC message;
  
this.textStop 1;
  
this.ts  text_speed;
  
endpage  false;
  
skippage false;
  new 
GuiBitmapCtrl("say3_mainwindow") {
    
extent  = {getimgwidth(layout_image), getimgheight(layout_image)};
    
position = {(GraalControl.extent[0]  - extent[0])  / 2, (GraalControl.extent[1] - extent[1]) / 4};
    
bitmap layout_image;
    
mode 1;
    
alpha layout_alpha;
    
active visible false;
    new 
GuiScrollCtrl("say3_scroll") {
      
useownprofile true;
      
profile.opaque true;
      
profile.border 0;
      
profile.fillcolor = {
          
0,  0,  0,  0
      
};
      
position = {1010};
      
extent = {say3_mainwindow.extent[0] - (position[0] * 2), say3_mainwindow.extent[1] - (position[1] * 2)-5};
      
hScrollBar "alwaysOff";
      
vScrollBar "alwaysOff";

      new 
GuiMLTextCtrl("say3_text") {
        
useownprofile true;
        
profile.fontcolor = {
          
61,23,0,225
        
};
        
position = {00};
        
extent   = {say3_scroll.extent[0], say3_scroll.extent[1]};
        
text     " ";
      }
    }
  }
  
say3_mainwindow.visible true;
  if (
message != NULL) {
    
setani(ganiNULL);
    
this.reading true;
    
disabledefmovement();
    
say3_mainwindow.show();
    
this.end false;
    new 
GuiTextCtrl("say3_text2") {
      
position = {say3_mainwindow.position[0]+20,say3_mainwindow.position[1] + say3_mainwindow.extent[1]-15};
      
height 20;
      
text  TEXT_S;
    }
    
this.punctuations = {'.','!','?',';',':'};
    
this.punctuations2 = {'.','!','?',';',':'};
    for (
this.newText 0this.newText message.length(); this.newText ++) { 
      
say3_text.text "<font size = 20><b>" message.substring(0this.newText) @ "</b></font>";
      
say3_scroll.scrollToBottom();
      if (
message.substring(this.newText-13) == "..."){
        
sleep(.5);
        
this.newText++;
        
say3_text.text "<font size = 20><b>" message.substring(0this.newText) @ "</b></font>";
        
sleep(.5);
        
this.newText++;
        
say3_text.text "<font size = 20><b>" message.substring(0this.newText) @ "</b></font>";
        
sleep(this.ts+1);
      }
      else if (
message.substring(this.newText-11in this.punctuations2){
        
sleep(this.ts .5);
      }
      else if (
message.substring(this.newText-11in this.punctuations){
        
sleep(this.ts 1);
      }
      else{
        
sleep(this.ts);
      }
      if (
skippage){
        break;
      }
    }

    
say3_text.text "<font size = 20><b>" message "</b></font>";
    
say3_scroll.scrollToBottom();
    
sleep(.5);
    if (
end == false){
      
endpage 1;
      
say3_text2.text TEXT_A;
    }
    else {
      
say3_text2.text TEXT_N;
    }
    
this.end true;

  }
}

function 
onDestroySay3() {
  
this.textStop 0;
  
say3_mainwindow.hide();
  
say3_text2.text ="";
  
this.reading false;
}



function 
onKeyPressed(key) {
  if (
key == 37 && this.ts >= .01 && this.reading){
    if (
this.ts => .3){
      
this.ts .3;
    }
    else {
      
this.ts += .02;
    } 
  }
  if (
key == 39 && this.ts <= .3 && this.reading){
    if (
this.ts <= .02){
      
this.ts .01;
    }
    else {
      
this.ts -= .02;
    } 
  } 
  if (
key == 39 && this.end && endpage != true){
    
endpage true;
    
this.textStop 0;
    
this.read++;
    
onDestroySay3();
  } 
  if (
key == 38 && this.end != true){
    
this.page--;
  }
  if (
key == 40 && this.end != true){
    
skippage true;
  }    
  if (
key == 65 && this.reading == true){
    
this.read++;
    
enabledefmovement();
    
onDestroySay3();
  }  

__________________

Digital Media Artist - David K? </3 (UnLoved)
www.davidkrout.com
www.twitch.com/DavidKkz



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 08:37 AM.


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