Please login or register.

Login with username, password and session length
Advanced search  

News:

For WME related articles and tutorials visit WME Resource Center.

Author Topic: dialogues and objects  (Read 3985 times)

0 Members and 1 Guest are viewing this topic.

YO

  • Our first adventure:
  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 32
    • View Profile
dialogues and objects
« on: November 02, 2010, 06:47:32 PM »

hi, here I am again, I have another little problem, this is about the talks, I have to talk with a NPC, lather I give some object and he says other dialogue, but the NPC doesn´t talks two diferent dialogues, I explain, change all their dialogue after giving the object.
this is the code have put in NPC.script:
Code: [Select]
global StateRoom;
global NPC;

on "Talk"
{
 if (StateRoom.book==2)
 {
  actor.GoTo(880 ,700);
  this.GoTo(550, 542);
  Game.Interactive = false;
  // greetings
  if(!StateRoom.TalkedToNPC) actor.Talk("Hola");
  else actor.Talk("Mmm");
  this.Talk("Que narices quieres, tengo mucho trabajo");

  // set the flag, so that we know we've already talked to him
  StateRoom.TalkedToNPC = true;

  // and let the dialogue begin

  NPCDialogue();
 
 
  // restore interactivity
  Game.Interactive = true;
  }
  else if (StateRoom.book==1)
  {
   actor.GoTo(880 ,700);
  this.GoTo(550, 542);
  Game.Interactive = false;
  // greetings
  if(!StateRoom.TalkedToNPC) actor.Talk("Hola");
  else actor.Talk("Mmm");
  this.Talk("Que narices quieres, tengo mucho trabajo");

  // set the flag, so that we know we've already talked to him
  StateRoom.TalkedToNPC = true;

  // and let the dialogue begin

  NPCDialogue2();
 
 
  // restore interactivity
  Game.Interactive = true;
    }
}
NPCDialogue is put after, in the book.script:
Code: [Select]
on "book"
{
  Game.Interactive = false;
  Game.DeleteItem("book");
  StateRoom.book = 1;

  Game.Interactive = true;
}
and in the Scene.init:
Code: [Select]
if(StateRoom==null)
{
  StateRoom.Visited = false;
  // add scene states here
 StateRoom.TalkedToNPC = false;
 StateRoom.book = 2;
}

i have create a variable called stateRoom.book that have two states, 1 or 2, depending if the actor gives the book or not, but dont work, only works after the actor gives to the NCP the book, if I talk before with the NPC dont talk
Logged
Henry y El libro magico, proximamente sacaremos la demo en español...
Henry and the magic book, demo coming soon in English

Kapryagos

  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 11
    • View Profile
    • casummer.eu
Re: dialogues and objects
« Reply #1 on: November 09, 2010, 11:34:28 PM »

I don't know if this will be helpful in any way,
but I also did a "npc-does-not-speak--change-var-then-npc-does-speak"-thing, and I solved by simply writing the beginning dialogue in two versions. Version #01 is the real dialogue, version #02 is the same but without any response by the npc excpt for "Sleep(3000);" ...
... I coded it that way that both dialogues are several functions, because that way I get the best overview.

Code: [Select]

var arisu_geheilt;

on "LeftClick"
{
Game.Interactive=false;
if(arisu_geheilt==1) {        // <== this is the var to be changed during another simple dialogue (without response box)
Arisudialog01();
} else {
Arisudialog02();
}
Game.Interactive=true;
}

As said, I don't know if I could help with that, but maybe it will give you a hint.
I merely wonder why you chose such a complex var -- even something like "var i;" would be enough to make it work. :)
Logged

Darky

  • Supporter
  • Regular poster
  • *
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 109
    • View Profile
    • Spreadcamp
Re: dialogues and objects
« Reply #2 on: November 10, 2010, 12:24:53 AM »

I believe the mistake is in that when you are deleting an item, the script of that item stops executing. Therefore in your case it never has a chance to change the value of "StateRoom.book" to 1

Try instead:
Code: Text
  1. on "book"
  2. {
  3.   Game.Interactive = false;
  4.   StateRoom.book = 1;
  5.   Game.Interactive = true;
  6.  
  7.   Game.DeleteItem("book");
  8. }
  9.  

That should fix it. :)

==============================

By the way in NPC.script if you are sure you don't need different GoTo etc. in your states why write it double? You could make your scripts more readable with something like like this if the initial approach and greetings stay the same in both the book cases:
Code: Text
  1. global StateRoom;
  2. global NPC;
  3.  
  4. on "Talk"
  5. {
  6.     actor.GoTo(880 ,700);
  7.     this.GoTo(550, 542);
  8.     Game.Interactive = false;
  9.  
  10.     // set the flag, so that we know we've already talked to him
  11.     StateRoom.TalkedToNPC = true;
  12.  
  13.     // greetings
  14.     if(!StateRoom.TalkedToNPC) actor.Talk("Hola");
  15.     else actor.Talk("Mmm");
  16.     this.Talk("Que narices quieres, tengo mucho trabajo");
  17.    
  18.     // and let the dialogue begin 
  19.     if (StateRoom.book == 2) NPCDialogue();
  20.     else if (StateRoom.book == 1) NPCDialogue2();
  21.    
  22.     // restore interactivity
  23.     Game.Interactive = true;
  24. }
  25.  
« Last Edit: November 10, 2010, 12:31:31 AM by Darky »
Logged

YO

  • Our first adventure:
  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 32
    • View Profile
Re: dialogues and objects
« Reply #3 on: November 10, 2010, 01:21:50 AM »

thanks, it works, I realize that the order of the lines matter a lot!!!
I try this with 3 actors, 2 of that are NPC and are in diferent Rooms, it works, but I found 1 failure, if I dont visit the room that have the script that change the variable, StateRoom.book = 1; the var doesnt change although I talk with the NPC, I solved this writing the script in one room that is visited alwais before all the rooms where the NPCs are. 
sorry but my english is not very good.
Logged
Henry y El libro magico, proximamente sacaremos la demo en español...
Henry and the magic book, demo coming soon in English
 

Page created in 0.068 seconds with 51 queries.