Please login or register.

Login with username, password and session length
Advanced search  

News:

Latest WME version: WME 1.9.1 (January 1st, 2010) - download

Author Topic: Problems with Game.AddResponseOnce()  (Read 9090 times)

0 Members and 1 Guest are viewing this topic.

Mac

  • Supporter
  • Regular poster
  • *
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 136
    • View Profile
    • Homepage
Problems with Game.AddResponseOnce()
« on: November 28, 2010, 08:25:39 PM »

Hi guys,

I actually have problems with the use of Game.AddResponseOnce(). Responses declared as "Once" appear to only display once a game. Here's an example of a piece the doesn't work:

Code: [Select]
function Dialog_Bibliothekar()
{

   Game.StartDlgBranch("Dialog_Bibliothekar");
     
      BibliothekarAufgewacht=true;
      actor.Talk("Hallo!");
      Bibliothekar.Talk("Hellas!");
     
      // Start of response loop
     
      var Select0;
      var Loop0 = true;
     
      while(Loop0)
      {
         
         if(QuizHalbzeit) Game.AddResponseOnce(0,"Haben sie ein Buch über Kriege und Schlachten?");
         Game.AddResponse(1,"Einen schönen Tag noch.");
         
         Select0 = Game.GetResponse();
         
         if(Select0==0)
         {
            actor.Talk("Haben sie ein Buch über Kriege und Schlachten?");
            Dialog_Bibliothekar_SchlachtenFragen();
         }
         
         if(Select0==1)
         {
            actor.Talk("Einen schönen Tag noch.");
            Loop0 = false;
         }
         
      }
     
   Game.EndDlgBranch("Dialog_Bibliothekar");
   
}


The variable QuizHalbzeit is true the whole time, but response 0 is only shown one time.
Any ideas someone?

Cheers
Mac
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: Problems with Game.AddResponseOnce()
« Reply #1 on: November 28, 2010, 10:45:31 PM »

it should work. So you are saying, that upon next entry of this dialogue eg. Game.Msg(QuizHalbzeit); shows true and the option is not there?
Logged
J.U.L.I.A. Enhanced Edition, Vampires!, J.U.L.I.A., J.U.L.I.A. Untold, Ghost in the Sheet

eborr

  • Regular poster
  • ***
  • Karma: 4
  • Offline Offline
  • Posts: 196
    • View Profile
Re: Problems with Game.AddResponseOnce()
« Reply #2 on: November 29, 2010, 12:09:57 AM »

I have had quite a lot of trouble with the Game.AddResponce one stuff.

One thing you might want to try is to close with

Game.EndDlgBranch();

without adding any value in the parentheses, I can't explain why but this works for me.
Logged

Mac

  • Supporter
  • Regular poster
  • *
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 136
    • View Profile
    • Homepage
Re: Problems with Game.AddResponseOnce()
« Reply #3 on: November 29, 2010, 12:38:46 AM »

Quote
So you are saying, that upon next entry of this dialogue eg. Game.Msg(QuizHalbzeit); shows true and the option is not there?

Yes, that's right. It behaves like '.AddResponseOnceGame' in this script.

Quote
I have had quite a lot of trouble with the Game.AddResponce one stuff.

One thing you might want to try is to close with

Game.EndDlgBranch();

without adding any value in the parentheses, I can't explain why but this works for me.

I'll try it to see what happens.
Logged

Mac

  • Supporter
  • Regular poster
  • *
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 136
    • View Profile
    • Homepage
Re: Problems with Game.AddResponseOnce()
« Reply #4 on: November 29, 2010, 11:54:34 PM »

I tried eborr's advice (and a few other things) but with no success. I've cut the script down a bit:
Code: [Select]
function Dialog_Bibliothekar()
{

   Game.StartDlgBranch("Dialog_Bibliothekar");
     
      BibliothekarAufgewacht=true;
      actor.Talk("Hallo!");
      Bibliothekar.Talk("Hellas!");
     
      // Start of response loop
     
      var Select0;
      var Loop0 = true;
     
      while(Loop0)
      {
         if(QuizHalbzeit) {
           Game.Msg(QuizHalbzeit);
           Game.AddResponseOnce(0,"Haben sie ein Buch über Kriege und Schlachten?");
         }
         Game.AddResponse(1,"Einen schönen Tag noch.");
         
         Select0 = Game.GetResponse();
         
         if(Select0==0)
         {
            actor.Talk("Haben sie ein Buch über Kriege und Schlachten?");
//            Dialog_Bibliothekar_SchlachtenFragen();
         }
         
         if(Select0==1)
         {
            actor.Talk("Einen schönen Tag noch.");
            Loop0 = false;
         }
         
      }
     
   Game.EndDlgBranch();//Dialog_Bibliothekar");
   
}

I still doesn't work. The game log says 'yes' when entering the section but the option is still not shown.
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: Problems with Game.AddResponseOnce()
« Reply #5 on: November 30, 2010, 07:02:37 PM »

This code should work. Please try renaming the DialogueBranch to something like "test1" to rule out naming conflict. Also try adding

Game.Msg(Game.GetCurrentDlgBranch());

before the branch is initialized, after the branch is initialized and after the EndDlgBranch() so you would rule out the bugs there.

I am using this method all the time, so I am pretty sure it works as my game is entirely based on this logic. As a sidenote, what WME version do you use?
Logged
J.U.L.I.A. Enhanced Edition, Vampires!, J.U.L.I.A., J.U.L.I.A. Untold, Ghost in the Sheet

Mac

  • Supporter
  • Regular poster
  • *
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 136
    • View Profile
    • Homepage
Re: Problems with Game.AddResponseOnce()
« Reply #6 on: November 30, 2010, 10:23:51 PM »

Oh, thanks. I missed the GetCurrentDlgBranch method, I guess this would've helped me a lot to see what's going wrong. To the version thing: I used 1.9.1, but tried out 1.8.1 yesterday to see if it's a version problem, but both version work the same. I'll play a bit with the GetCurrentDlgBranch method and see what I can find out. Thanks.
Logged

Mac

  • Supporter
  • Regular poster
  • *
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 136
    • View Profile
    • Homepage
Re: Problems with Game.AddResponseOnce()
« Reply #7 on: November 30, 2010, 11:31:18 PM »

Got it!

I just found out that the error only occurs if I enter another scene first. In that scene I had an automatic background dialog between two characters (you enter the scene while they are talking to each other). That function looked like this:
Code: [Select]
function Dialog_Wachen_Streitgespraech()
{

//   Game.StartDlgBranch("Dialog_Wachen_Streitgespraech");
     
      while(true) {
      if(WachenStreiten) {
      Tuerke.Talk("Bist du konkret Ochse vom Horn!");
      } else break;
      if(WachenStreiten) {
      Grieche.Talk("Bitte was?");
      } else break;
      if(WachenStreiten) {
      Tuerke.Talk("Äh, isch meine Horn vom Ochse!");
      } else break;
      if(WachenStreiten) {
      Grieche.Talk("Du tickst doch nicht sauber! Was soll denn das sein?");
      } else break;
     .
     .
     .
     } // while
//   Game.EndDlgBranch("Dialog_Wachen_Streitgespraech");
}
As you can see I used a dialog branch for it too and that one caused the error, because when my main character left the scene, the script/function was destroyed, but the dialogue branch was still open. So now I erased the dialogue branching in this function and it works. You can say it was something like "dialogue branching overkill"  ;D

I have to rework my dialogue editor tool to only add dialogue branches when they are needed (if a response box is involved). Right now it adds a dialogue branch for every function it creates, which seems to be dangerous.

Thanks for your help.

Cheers
Mac
Logged

eborr

  • Regular poster
  • ***
  • Karma: 4
  • Offline Offline
  • Posts: 196
    • View Profile
Re: Problems with Game.AddResponseOnce()
« Reply #8 on: December 01, 2010, 11:30:34 AM »

pleased you found the source of your problem, as stated before I have battled with this in the past, the best way I have found to manage the challenge of not having "rougue" dialogue branches is to put all response box activities within function calls, then to have a StartDlgBranch/EndDilgBranch() pairing around the function call, this might seem clumsy to more accomplished coders, but I am a bear with a very little brain.
Logged
 

Page created in 0.032 seconds with 21 queries.