Please login or register.

Login with username, password and session length
Advanced search  

News:

IRC channel - server: waelisch.de  channel: #wme (read more)

Pages: [1] 2  All

Author Topic: "Visual Novel"-like talk window // or: like in "Alpha Polaris"  (Read 13069 times)

0 Members and 1 Guest are viewing this topic.

Ryouko

  • Clumpsy, tea loving artist~
  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Gender: Female
  • Posts: 23
  • Uhm... nothing to say here! =D
    • View Profile
"Visual Novel"-like talk window // or: like in "Alpha Polaris"
« on: December 25, 2011, 04:59:17 PM »

Hi there, guys! =D
Yeah, me again...

So, as a Visual Novel fan (yeah, my previous engine was not only the RMXP, but also Ren'Py - actually, still using it) I wanted to have a different talk window.
Just like in the game >>Alpha Polaris<<:

This is exactly what I want. *-*
With the difference that I'd like to use animated sprites (talk & idle animation) and I'd like to have a second field for text (e.g. at the bottom with a smaller font for things that are whispered), but this are details. Once I have the general script I'll probably be able to edit it.
I've seen threads with people trying to modify the talk window (for speech bubbles etc.), but I kinda don't get it.
While the graphical isn't a problem for me, the scripting part is.
But I'm willing to learn - I'd really appreciate it if somebody could take the time to help me out!

Thanks in advance. <3

- Ryouko
Logged

Mnemonic

  • WME developer
  • Administrator
  • Addicted to WME forum
  • *
  • Karma: 41
  • Offline Offline
  • Gender: Male
  • Posts: 5683
    • View Profile
    • Dead:Code Site
Re: "Visual Novel"-like talk window // or: like in "Alpha Polaris"
« Reply #1 on: December 26, 2011, 06:30:06 PM »

Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum. ::wave

Ryouko

  • Clumpsy, tea loving artist~
  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Gender: Female
  • Posts: 23
  • Uhm... nothing to say here! =D
    • View Profile
Re: "Visual Novel"-like talk window // or: like in "Alpha Polaris"
« Reply #2 on: December 26, 2011, 08:18:44 PM »

Hello~ =)

I looked at this and it looked quite promising!
But when I tried it out I just couldn't get it to work.
I just added it as a new script in the script subfolder. =o
Or is it supposed to be in the actor section?
Sorry, I'm really quite the beginner here. ^^"
But thank you for your help again. <3

- Ryouko
Logged

Ryouko

  • Clumpsy, tea loving artist~
  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Gender: Female
  • Posts: 23
  • Uhm... nothing to say here! =D
    • View Profile
Re: "Visual Novel"-like talk window // or: like in "Alpha Polaris"
« Reply #3 on: December 28, 2011, 01:33:47 AM »

Huh...
okay, so it's in the actor script.
Managed to get it to work, yay~

Only problem is that I want the window to be as big as the text (I use a window with a tiled image), but kinda don't know how to do so.
I know that this can be done with a static thingy, but how do I attach the dialog text with the static text?
Is there a way to say something like "srcString = [name of the static]"?
This would be amazing. <3

Also, is there a way to make the text appear letter by letter? =o
It looks dull if the whole text just suddenly appears as a whole.

Thank you for your time~
Logged

Mnemonic

  • WME developer
  • Administrator
  • Addicted to WME forum
  • *
  • Karma: 41
  • Offline Offline
  • Gender: Male
  • Posts: 5683
    • View Profile
    • Dead:Code Site
Re: "Visual Novel"-like talk window // or: like in "Alpha Polaris"
« Reply #4 on: December 28, 2011, 03:13:12 PM »

To assign text to the static control you would do something like this (in the window's script):

Code: WME Script
  1. var myStatic = this.GetControl("name_of_your_static_control");
  2. myStatic.Text = "Hello world";
  3.  


Displaying it char by char would require some more code (untested, I'm writing it from the top of my head):

Code: WME Script
  1. var myStatic = this.GetControl("name_of_your_static_control");
  2. myStatic.Text = "";
  3.  
  4. var text = new String("Hello world");
  5. for (var i = 0; i < text.Length; i = i + 1)
  6. {
  7.   myStatic.Text = myStatic.Text + text.Substr(i, 1);
  8.   Sleep(20);
  9. }
  10.  
Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum. ::wave

Mnemonic

  • WME developer
  • Administrator
  • Addicted to WME forum
  • *
  • Karma: 41
  • Offline Offline
  • Gender: Male
  • Posts: 5683
    • View Profile
    • Dead:Code Site
Re: "Visual Novel"-like talk window // or: like in "Alpha Polaris"
« Reply #5 on: December 28, 2011, 03:15:16 PM »

And if I may suggest something, if you are a beginner, start with some game logic instead, don't start with user interface, because custom user interfaces can become rather complex, and they might unnecessarily frustrate/demotivate you :)
Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum. ::wave

Ryouko

  • Clumpsy, tea loving artist~
  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Gender: Female
  • Posts: 23
  • Uhm... nothing to say here! =D
    • View Profile
Re: "Visual Novel"-like talk window // or: like in "Alpha Polaris"
« Reply #6 on: January 29, 2012, 03:17:09 PM »

Hello! =)
(Sorry for answering so late, needed a break from scripting and focused on the drawings instead.)

THANK YOU SO MUCH! x3
The text is now displayed in the speech bubble! <3

Currently, it works like this:

* Actor script
Code: WME Script
  1. method Talk(Inhalt,Notiz,Stimmung)
  2. {
  3.  
  4.                 var laune;
  5.         if (Stimmung == null) laune = "norm1"; // basic window, right side
  6.         else
  7.         laune = Stimmung; // andere
  8.        
  9.         var tmpState = Game.Interactive;
  10.         Game.Interactive = false// we save the interactivity state for later and turn it off
  11.  
  12.         var dlgWin = Game.LoadWindow("interface/talk/"+laune+".window"); // load the dialogue window
  13.         var talkRobotEnt = Scene.CreateEntity()// create the entity used for talking
  14.                
  15.                 text1 = Inhalt;
  16.                 note1 = Notiz;
  17.                
  18.         //dlgWin.SetImage("Talk/"+twin+".image");   // set the image
  19.         dlgWin.Y = 250;
  20.                                        
  21.        
  22.         talkRobotEnt.SetFont("fonts\sserif.font"); // set the speech font
  23.  
  24.         talkRobotEnt.SoundPanning = false// make the sound centered
  25.         talkRobotEnt.Talk(Inhalt,Notiz, "", "", 0)// say the line
  26.                
  27.         Game.UnloadObject(dlgWin)// dispose of the window
  28.         Scene.DeleteEntity(talkRobotEnt); // kill the talk entity}
  29.        
  30.         Game.Interactive = tmpState;   
  31.                
  32. }
* Static script (2 in this window)
Code: WME Script
  1. this.Text = text1;
Code: WME Script
  1. this.Text = note1;
(text1 and note1 are global variables defined in the Basescript.)

I currently have the problem that it auto-closes itself after a short time, and that I don't really get the letter-by-letter to work.

But coming this far, I really have to thank you! <3
I always fail at scripting but now I nearly have my talksystem.
Thank you! =)

- R.
« Last Edit: February 03, 2012, 11:21:37 AM by Ryouko »
Logged

metamorphium

  • Global Moderator
  • Addicted to WME forum
  • *
  • Karma: 12
  • Offline Offline
  • Gender: Male
  • Posts: 1511
  • Vampires!
    • View Profile
    • CBE  software s.r.o.
Re: "Visual Novel"-like talk window // or: like in "Alpha Polaris"
« Reply #7 on: January 29, 2012, 09:10:23 PM »

The way how your Talk works imply the window would close.

Code: WME Script
  1.  
  2.     talkRobotEnt.Talk(Inhalt,Notiz, "", "", 0)// say the line
  3.                
  4.         Game.UnloadObject(dlgWin)// dispose of the window
  5.         Scene.DeleteEntity(talkRobotEnt); // kill the talk entity}
  6.  
  7.  

The trick is that you delete the window (UnloadObject) as soon as talkRobotEnt.Talk ends talking. Now talk either synchronize with voiceover file (stays as long as the voiceover file is played) or has some default value calculated from the text length.

First of all, if you plan to use the voiceovers, it's always better to use automatic speech (based on key from string.tab), then having to manually state what file should be played. However, if you don't have voiceovers now, you can specify longer period directly in Talk.

Code: WME Script
  1.  
  2. //We'll add optional displayLength parameter (in miliseconds) which if specified will say how long the line should be!
  3.  
  4. method Talk(Inhalt,Notiz,Stimmung, displayLength)
  5. {
  6.  
  7.                 var laune;
  8.         if (Stimmung == null) laune = "norm1"; // basic window, right side
  9.         else
  10.         laune = Stimmung; // andere
  11.        
  12.         var tmpState = Game.Interactive;
  13.         Game.Interactive = false// we save the interactivity state for later and turn it off
  14.  
  15.         var dlgWin = Game.LoadWindow("interface/talk/"+laune+".window"); // load the dialogue window
  16.         var talkRobotEnt = Scene.CreateEntity()// create the entity used for talking
  17.                
  18.                 text1 = Inhalt;
  19.                 note1 = Notiz;
  20.                
  21.         //dlgWin.SetImage("Talk/"+twin+".image");   // set the image
  22.         dlgWin.Y = 250;
  23.                                        
  24.        
  25.         talkRobotEnt.SetFont("fonts\sserif.font"); // set the speech font
  26.  
  27.         talkRobotEnt.SoundPanning = false// make the sound centered
  28.         talkRobotEnt.Talk(Inhalt,Notiz, displayLength, "", 0)// say the line
  29.                
  30.         Game.UnloadObject(dlgWin)// dispose of the window
  31.         Scene.DeleteEntity(talkRobotEnt); // kill the talk entity}
  32.        
  33.         Game.Interactive = tmpState;   
  34.                
  35. }
  36.  

Untested but should work. :)))

Hope this helps.
Logged
J.U.L.I.A. Enhanced Edition, Vampires!, J.U.L.I.A., J.U.L.I.A. Untold, Ghost in the Sheet

Ryouko

  • Clumpsy, tea loving artist~
  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Gender: Female
  • Posts: 23
  • Uhm... nothing to say here! =D
    • View Profile
Re: "Visual Novel"-like talk window // or: like in "Alpha Polaris"
« Reply #8 on: January 29, 2012, 10:30:16 PM »

Ah, I see!
Thank you for explaining. =)
(Yeah, sadly not using voiceovers. <_<)
Is there also a way to close the message when clicking?
I'm not really a fan of auto-close stuff as it's kinda... I don't know, I just can't relax when I know that it'll close itself sometime.

- R.
Logged

Ryouko

  • Clumpsy, tea loving artist~
  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Gender: Female
  • Posts: 23
  • Uhm... nothing to say here! =D
    • View Profile
Re: "Visual Novel"-like talk window // or: like in "Alpha Polaris"
« Reply #9 on: January 30, 2012, 02:57:47 PM »

I looked at your code again, Mnemonic, and I got the letter-by-letter to work. <3
Thank you. :>
Now I just need to correct the auto-close~
This just... suddenly worked?
Oh, it just died again.

Also, the text (first parameter, "Inhalt") is not only displayed in the static/the speechbubble, but also at the top left corner of the screen.
Guess this happened since I overwrote the talk methode?
I there a way to fix that?

- R.

PS. This is by far the most supportive board I've ever been in - thank you. x3
« Last Edit: January 30, 2012, 10:10:57 PM by Ryouko »
Logged

Ryouko

  • Clumpsy, tea loving artist~
  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Gender: Female
  • Posts: 23
  • Uhm... nothing to say here! =D
    • View Profile
Re: "Visual Novel"-like talk window // or: like in "Alpha Polaris"
« Reply #10 on: January 31, 2012, 02:39:00 PM »

Alrighty, some things worked. <3
The speechbubble works nearly perfectly now, only problem is still the auto-close.
(I thought that it might would work with the on LeftClick thingy, but this wasn't the case.)
Anyone got an idea how to make it work?
Code: WME Script
  1. #include "scripts\base.inc"
  2.  
  3. method Talk(Inhalt,Notiz,Stimmung)
  4. {
  5.                 var text1 = Inhalt;
  6.                 var note1 = Notiz;
  7.                 var laune;
  8.         if (Stimmung == null) laune = "norm1"; // basic window, right side
  9.         else
  10.         laune = Stimmung; // andere
  11.  
  12.         var dlgWin = Game.LoadWindow("interface/talk/norm1.window"); // load the dialogue window
  13.         dlgWin.SetImage("ui_elements/talk/"+laune+".png");
  14.         dlgWin.Y = 250;
  15.         var textbox = dlgWin.GetControl("text");
  16.         var notebox = dlgWin.GetControl("note");
  17.                
  18.         notebox.Text = "";
  19.         textbox.Text = "";
  20.         var lettera = new String(text1);
  21.         for (var i = 0; i < lettera.Length; i = i + 1)
  22.                 {textbox.Text = textbox.Text + lettera.Substr(i, 1);
  23.                 Sleep(50);}
  24.                        
  25.         var letterb = new String(note1);
  26.         for (var j = 0; j < letterb.Length; j = j + 1)
  27.                 {notebox.Text = notebox.Text + letterb.Substr(j, 1);
  28.                 Sleep(50);}                                                  
  29.                
  30.         Game.UnloadObject(dlgWin)// dispose of the window   
  31. }
Also, for the ones that might want to use it:
"Inhalt" (engl.: "content") is a static in the window named "text" and also the maintext in the box.
"Notiz" (engl.: "note") is a static named "note" and is below the speechbubble to make it seem like it was whispered.
"Stimmung" (engl.: "mood") is the background image of the window.

So, once the auto-close is gone it's perfect. x3
Thank you all for the help so far. :>

- R.
« Last Edit: February 03, 2012, 11:21:52 AM by Ryouko »
Logged

Mnemonic

  • WME developer
  • Administrator
  • Addicted to WME forum
  • *
  • Karma: 41
  • Offline Offline
  • Gender: Male
  • Posts: 5683
    • View Profile
    • Dead:Code Site
Re: "Visual Novel"-like talk window // or: like in "Alpha Polaris"
« Reply #11 on: January 31, 2012, 06:37:59 PM »

I think you'd need to reorganize things a little. Basically move all the display logic to the window itself, and the original script will just instantiate the window and wait for it to close.

Code: WME Script
  1. // load the window
  2. var dlgWindow = Game.LoadWindow("some path");
  3.  
  4. // fill in the required dialog properties
  5. dlgWindow.Inhalt = "whatever";
  6. dlgWindow.Stimmung = "whatever";
  7. dlgWindow.SomeProp = "some value";
  8.  
  9. // init the window and start the text display
  10. dlgWindow.ApplyEvent("DoYourStuff");
  11.  
  12. // this is crucial, it will pause this script until the window closes
  13. dlgWindow.GoExclusive();
  14.  
  15. // we're done, unload
  16. Game.DeleteWindow(dlgWindow);
  17.  

And the actual processing would happen in the window's script:

Code: WME Script
  1. // the other script wants us to do the magic
  2. on "DoYourStuff"
  3. {
  4.   // notice that you can access the properties passed by the original script using this.SomeProperty notation
  5.  
  6.   var laune;
  7.   if (this.Stimmung == null) laune = "norm1";
  8.   else laune = Stimmung;
  9.  
  10.         this.SetImage("ui_elements/talk/"+laune+".png");
  11.  
  12.   ...etc
  13. }
  14.  

Now you have control over when the window closes and the original script will just wait. So for example you can add to its script:

Code: WME Script
  1. on "LeftClick"
  2. {
  3.   this.Close();
  4. }
  5.  

Or some more elaborate closing mechanism if you require.
Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum. ::wave

Ryouko

  • Clumpsy, tea loving artist~
  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Gender: Female
  • Posts: 23
  • Uhm... nothing to say here! =D
    • View Profile
Re: "Visual Novel"-like talk window // or: like in "Alpha Polaris"
« Reply #12 on: January 31, 2012, 09:36:05 PM »

Ah, this makes sense!
Thanks. :>

Code: [Select]
// fill in the required dialog properties
dlgWindow.Inhalt = "whatever";
But I don't quite understand that part - is "whatever" the name of the static, or something else? =o [Variables?]
<= Well, probably it's something else as I couldn't get it to work? The window doesn't seem to understand that the event occured.
And the first piece of code is still in a "methode Talk(parameter)"-thingy, or isn't it?

- R.
Logged

Ryouko

  • Clumpsy, tea loving artist~
  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Gender: Female
  • Posts: 23
  • Uhm... nothing to say here! =D
    • View Profile
Re: "Visual Novel"-like talk window // or: like in "Alpha Polaris"
« Reply #13 on: January 31, 2012, 10:46:00 PM »

Alright, the event starts now, but the method parameters are not defined.
(Guess that's the dlgWindow.ParameterHere thingy?)
We are nearly there, thank you for the help. :>

- R.
Logged

metamorphium

  • Global Moderator
  • Addicted to WME forum
  • *
  • Karma: 12
  • Offline Offline
  • Gender: Male
  • Posts: 1511
  • Vampires!
    • View Profile
    • CBE  software s.r.o.
Re: "Visual Novel"-like talk window // or: like in "Alpha Polaris"
« Reply #14 on: January 31, 2012, 11:18:14 PM »

would be the best if you post the scripts which are troubling you. :)

also change this:

Code: WME Script
  1. var lettera = new String(text1);
  2.  

to

Code: WME Script
  1. var lettera = new String(Game.ExpandString(text1));
  2.  

You'll thank me later. :)
Logged
J.U.L.I.A. Enhanced Edition, Vampires!, J.U.L.I.A., J.U.L.I.A. Untold, Ghost in the Sheet
Pages: [1] 2  All
 

Page created in 0.132 seconds with 20 queries.