Please login or register.

Login with username, password and session length
Advanced search  

News:

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

Author Topic: Gits like talk window  (Read 12799 times)

0 Members and 2 Guests are viewing this topic.

metamorphium

  • Global Moderator
  • Addicted to WME forum
  • *
  • Karma: 12
  • Offline Offline
  • Gender: Male
  • Posts: 1511
  • Vampires!
    • View Profile
    • CBE  software s.r.o.
Gits like talk window
« on: August 04, 2008, 11:25:20 AM »

I was many times already asked how I did in Ghost in the Sheet the talk window. So I've decided to share the code. Basically it works like this. I have a couple of images with special characters (Larisa, Scott etc.) named approprietly.

when my Talk method is called, it takes 3 parameters: srcString (line to speak), srcActor (which is used to select propper image for the speaking character and xPosition which sets the
start of the talk text block (some images are at the beginning of the window, some at the end).

As most of the lines are spoken by Ghost, the defaults are set to the window so you can call it like

Ghost.Talk("blabla");

if you need reply from Larisa, it would be:

Ghost.Talk("blablabla", "larisa", 500);


Code: WME Script
  1. method Talk(srcString,srcActor,xPosition)
  2. {
  3.  
  4.         var twin;
  5.         if (srcActor == null) twin = "talk"; // basic window with ghost
  6.         else
  7.         twin = srcActor; // NPC window
  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("windows\dlgWindow.window"); // load the dialogue window
  13.         var  talkRobotEnt = Scene.CreateEntity()// create the entity used for talking
  14.         var tString = Game.ExpandString(srcString)// prepare the localized string to handle formatting
  15.         var tLength = tString.Length;
  16.         var lines = ToInt(tLength / 300) + 1; // find out how many lines will we need
  17.                
  18.         dlgWin.SetImage("windows/"+twin+".png");   // set the image
  19.         dlgWin.Y = 425
  20.                
  21.         // set the caption parameters
  22.         talkRobotEnt.SubtitlePosRelative = false;
  23.         talkRobotEnt.SubtitlesPosXCenter = false;
  24.         talkRobotEnt.SubtitlesWidth = 680;
  25.         talkRobotEnt.SubtitlesPosX = 90;       
  26.        
  27.         if (xPosition != null) talkRobotEnt.SubtitlesPosX = xPosition;
  28.        
  29.                        
  30.         talkRobotEnt.SubtitlesPosY = 630 + 15* lines;  // position the caption in the window based on number of lines
  31.  
  32.        
  33.         talkRobotEnt.SetFont("fonts\verdana.font"); // set the speech font
  34.  
  35.         talkRobotEnt.SoundPanning = false// make the sound centered
  36.         talkRobotEnt.Talk(srcString, null, "", "", 0)// say the line
  37.        
  38.         Game.UnloadObject(dlgWin)// dispose of the window
  39.         Scene.DeleteEntity(talkRobotEnt); // kill the talk entity
  40.        
  41.         Game.Interactive = tmpState;   
  42.  
  43. }
  44.  


Nowadays I'd make it a bit differently, but you get the idea...
« Last Edit: August 04, 2008, 11:28:37 AM by metamorphium »
Logged
J.U.L.I.A. Enhanced Edition, Vampires!, J.U.L.I.A., J.U.L.I.A. Untold, Ghost in the Sheet

Drake

  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 1
    • View Profile
Re: Gits like talk window
« Reply #1 on: August 04, 2008, 12:01:22 PM »

Hey this is great! You rock! ::rock
Thank you very much!

PS: First post on the board! ;D
Logged

Jyujinkai

  • Global Moderator
  • Frequent poster
  • *
  • Karma: 1
  • Offline Offline
  • Posts: 352
    • View Profile
    • Jyujinkai's WME Development Blog
Re: Gits like talk window
« Reply #2 on: August 05, 2008, 03:29:49 AM »

please post an image or 2?
Logged
<Antoine de Saint-Exupéry> In any thing at all, perfection is finally attained not when there is no longer anything to add, but when there is no longer anything to take away...
<Carl Sagan> If you want to make a apple pie from scratch. You must first... invent the universe

Jyujinkai

  • Global Moderator
  • Frequent poster
  • *
  • Karma: 1
  • Offline Offline
  • Posts: 352
    • View Profile
    • Jyujinkai's WME Development Blog
Re: Gits like talk window
« Reply #3 on: August 11, 2008, 04:37:51 AM »

can we please get a screenshot or somthing.. so we canunderstand why this "talk" window is cool?
Logged
<Antoine de Saint-Exupéry> In any thing at all, perfection is finally attained not when there is no longer anything to add, but when there is no longer anything to take away...
<Carl Sagan> If you want to make a apple pie from scratch. You must first... invent the universe

metamorphium

  • Global Moderator
  • Addicted to WME forum
  • *
  • Karma: 12
  • Offline Offline
  • Gender: Male
  • Posts: 1511
  • Vampires!
    • View Profile
    • CBE  software s.r.o.
Re: Gits like talk window
« Reply #4 on: August 11, 2008, 06:59:32 AM »

uhm, I thought the people asking for that code actually saw gits in action. :P

http://www.ghostinthesheet.com/dialog.jpg
Logged
J.U.L.I.A. Enhanced Edition, Vampires!, J.U.L.I.A., J.U.L.I.A. Untold, Ghost in the Sheet

Jyujinkai

  • Global Moderator
  • Frequent poster
  • *
  • Karma: 1
  • Offline Offline
  • Posts: 352
    • View Profile
    • Jyujinkai's WME Development Blog
Re: Gits like talk window
« Reply #5 on: August 11, 2008, 03:43:04 PM »

Thanks Meta

uhm, I thought the people asking for that code actually saw gits in action. :P

true.. but random people in community hunting for code snipits in the "Scripts, plugins, utilities, goodies" area of forum... may not have played GITS but still be interested in chat ideas.
Logged
<Antoine de Saint-Exupéry> In any thing at all, perfection is finally attained not when there is no longer anything to add, but when there is no longer anything to take away...
<Carl Sagan> If you want to make a apple pie from scratch. You must first... invent the universe

Chris

  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 31
    • View Profile
Re: Gits like talk window
« Reply #6 on: October 21, 2009, 07:17:20 PM »

 can't use with animation charecter . plese help me

how do use "method Talk" with animation charecter ???
Logged
 

Page created in 0.103 seconds with 25 queries.