Please login or register.

Login with username, password and session length
Advanced search  

News:

This forum provides RSS feed. To query recent posts use this url. More...


Author Topic: talk method  (Read 3299 times)

0 Members and 1 Guest are viewing this topic.

eborr

  • Regular poster
  • ***
  • Karma: 4
  • Offline Offline
  • Posts: 196
    • View Profile
talk method
« on: July 07, 2009, 12:50:08 AM »

I have been battling with a revised talk method, with only limited success.  I can get something working after a fashion but it's horribly crude.

I have been through the documentation and the forum and I think I am getting some insights, perhaps you can check my assumptions. I have looked at the code section from ghost in the machine which has given me some inspiration

I have created a basic talk method which I have attached to an object, I then call the method from the object and pass various paramters through.

I had a lot of trouble understanding where the code for the method should be stored, in the end I just attached a file in the testbed scene directory which worked ok.

1. If I want to revise the talk method for an actor do I put that method in the actor script or in some other locations, I tried putting stuff in game.script but that didn't work.

2. If I want an npc to talk how do I associate a revised talk method with that character, assuming his representation is just a sprite object - would that be as some attachement in the sprite editor ?

3. Having read the documentation, there is a clear recommendation that a custom window should be used to hold the image, ok so I can create a custom  window using the window editor tool, and can do stuff like set image.  What I would like to do is to put an image on a  static control programatically, can anyone provide me with a code snippet as an example of how this could be done.

Sorry for this post and the very naive nature of these questions.





« Last Edit: July 07, 2009, 12:52:27 AM by eborr »
Logged

Catacomber

  • Supporter
  • Frequent poster
  • *
  • Karma: 0
  • Offline Offline
  • Gender: Female
  • Posts: 443
  • I love mice.
    • View Profile
    • Catacomber.com
Re: talk method
« Reply #1 on: July 07, 2009, 05:05:55 AM »

I can answer part of your question--I think my system is different from yours but I attach the script to the sprite npc in the scene.  For example, here is a script for a sprite entity called Nina [She's not an entity, just a sprite entity in a scene]:

You have to make a variable for your speaking sprite then code the state changes.  You need a window or something to hold the text.  The "loc" thing that holds the text box is on my "hud" which is a window that sits over every scene. 

Before I had a face appear for the speaking character but it was a lot of coding work and no one seemed to be that interested in it. But that's how Broken Sword I (I think it's one) works and it's nice.   : )


Code: WME Script
  1. #include "scripts\base.inc"
  2.  
  3. var Entnina = Scene.GetNode("nina");
  4. var nin;
  5.  
  6. on "LeftClick"
  7. {
  8. if(nin==null)
  9. {var x = hud.GetControl("loc");
  10. x.Text = "INGRID: Nina, we have been companions now for a long time. I'll miss you. |NINA: Miss, you're so foolish to trust the Konung. Don't go to that island. Whenever I'm anxious I crave one of those delicious little cakes you make. I wish I had one now.";
  11. }
  12. else
  13. {
  14. if(nin==2)
  15. {
  16. x.Text = "NINA: Miss, I'll meet you on the island. Maybe I'll be able somehow to help."
  17. }
  18. }
  19. }
  20.  
  21.  
  22. on "Cupcake"       
  23.  
  24. {
  25. var x = hud.GetControl("loc");
  26. x.Text = "INGRID: Nina, I need the doorknob to open the door. The Konung has given me permission to leave. Will you give me the doorknob if I tempt you with your favorite sweet? |NINA: You're so foolish to trust the Konung. Take the knob but you'll have to restore the broken combination lock to leave.  The pieces are on the floor. I'll follow you to the island and try to help.";
  27. Game.TakeItem("nkey");
  28. nin=2;
  29. Game.DeleteItem("Cupcake");
  30. }
  31.  
  32.  
  33.  

« Last Edit: July 07, 2009, 05:07:42 AM by Catacomber »
Logged
http://www.catacomber.com/
Code: WME Script
  1. Mnemonic is wonderful.
  2.  

Mnemonic

  • WME developer
  • Administrator
  • Addicted to WME forum
  • *
  • Karma: 41
  • Offline Offline
  • Gender: Male
  • Posts: 5683
    • View Profile
    • Dead:Code Site
Re: talk method
« Reply #2 on: July 07, 2009, 09:30:12 AM »

Quote
1. If I want to revise the talk method for an actor do I put that method in the actor script or in some other locations, I tried putting stuff in game.script but that didn't work.
You are extending an actor, so you want to put the customized Talk method to some of the scripts attached to the actor. Either to the default actor's script, or you can create a new script which handles a customized talking and attach the same script to multiple actors.

Quote
2. If I want an npc to talk how do I associate a revised talk method with that character, assuming his representation is just a sprite object - would that be as some attachement in the sprite editor ?
Nothing is ever just a sprite, it's either an actor or a scene entity (which is basically a simplified actor that doesn't walk etc.). So again, you want to extend some entity, you need to attach the script with custom Talk method to said entity. It's logical, you just have to get used to this "object oriented" way of thinking :)

Quote
3. Having read the documentation, there is a clear recommendation that a custom window should be used to hold the image, ok so I can create a custom  window using the window editor tool, and can do stuff like set image.  What I would like to do is to put an image on a  static control programatically, can anyone provide me with a code snippet as an example of how this could be done.
First you need a reference to the parent window. You get it at the moment when you're loading the window.

Code: WME Script
  1. var SomeWindow = Game.LoadWindow("path\some.window");
  2.  

Now SomeWindow variable contains a reference to your window (you would use global instead of var if you want to access the window from other scripts). Windows provide access to their controls using the GetControl() method.

Code: WME Script
  1. var SomeStaticControl = SomeWindow.GetControl("static_control_name_here");
  2.  

And once you obtained a reference to the static control, you can use its SetImage() method.

Code: WME Script
  1. SomeStaticControl.SetImage("path\some_image.png");
  2.  
Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum. ::wave

eborr

  • Regular poster
  • ***
  • Karma: 4
  • Offline Offline
  • Posts: 196
    • View Profile
Re: talk method
« Reply #3 on: July 08, 2009, 11:26:43 AM »

thanks very much for your help with this. I am very happy with the results.
Logged
 

Page created in 0.067 seconds with 20 queries.