Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Benjiman33 on Sat 28/08/2010 22:09:02

Title: Pb label text when changing room **SOLVED**
Post by: Benjiman33 on Sat 28/08/2010 22:09:02
Hello I have a small question :)

I have created a "map" where ShowplayerCharacter is on false. I have created some hotspots that are supposed to represent other rooms, and i have allowed leftclick for these hotspots. However I want the player to make a leftclick on the hotspot and to change room. I have just written for the hotspot hMixte the following function:

function hMixte_AnyClick()
{
player.ChangeRoom(3, 330, 65);
}

It works but when my mouse move over the hotspot my label text shows lots of hMixte !!!

(http://imgur.com/kVhan.png)

The text "MixteMixteMixte..." just appears when ShowplayerCharacter is on false... I have tried to set it true and to make the player transparent but the leftclick does not work anymore...
How can I avoid that ? Or how can I simply make the player room change with a leftclick ?
Title: Re: Pb label text when changing room
Post by: Khris on Sun 29/08/2010 02:37:20
Are you using a template or module?
Title: Re: Pb label text when changing room
Post by: Benjiman33 on Sun 29/08/2010 11:13:09
I'm not using a module, just the indiana jones' GUI that I have modified... (only graphically i did not change its properties)
I just want to make a changeroom with a leftclick...
Title: Re: Pb label text when changing room
Post by: Khris on Sun 29/08/2010 11:59:53
Which one are you using?
Can you post the repeatedly_execute from global.asc?
Title: Re: Pb label text when changing room
Post by: Benjiman33 on Sun 29/08/2010 12:14:56
Thanks for helping Khris :)
Here we go:
function repeatedly_execute() {
 
  if (mouse.Mode == eModeWalkto) {
    buffer_action = "Marcher vers ";
  } else {
    if (mode_complementaire == "REGARDER") {buffer_action = "Regarder ";}
    if (mode_complementaire == "PRENDRE")  {buffer_action = "Prendre ";}
    if (mode_complementaire == "TIRER")    {buffer_action = "Tirer ";}
    if (mode_complementaire == "POUSSER")  {buffer_action = "Pousser ";}
    if (mode_complementaire == "PARLER")   {buffer_action = "Parler à ";}
    if (mode_complementaire == "UTILISER") {buffer_action = "Utiliser ";}
    if (mode_complementaire == "DONNER")   {buffer_action = "Donner ";}
    if (mode_complementaire == "OUVRIR")   {buffer_action = "Ouvrir ";}
    if (mode_complementaire == "FERMER")   {buffer_action = "Fermer ";}

    if (mouse.Mode == eModeUseinv) {
      if (ancienne_action == "Donner ") buffer_action = inventaire_action.Append(" à ");
      if (ancienne_action == "Utiliser ") buffer_action = inventaire_action.Append(" avec ");
    } else {
      ancienne_action = buffer_action;
    }
  }

  buffer_objet = Game.GetLocationName(mouse.x , mouse.y );
  if (buffer_action != null) {
    buffer_action = buffer_action.Append(buffer_objet);
    lblHS.TextColor = COULEUR_TEXTE_NORMAL;
  lblHS.Text = buffer_action;
    if (mouse.Mode != eModeUseinv) inventaire_action = buffer_action;
  }


  if (mouse.Mode == eModeWalkto) {
    mode_complementaire_defaut = "";
    if (GetLocationType(mouse.x,mouse.y) == eLocationNothing) {
      InventoryItem *II = InventoryItem.GetAtScreenXY(mouse.x, mouse.y); 
      if (II != null) { mode_complementaire_defaut = II.GetTextProperty("defaction"); }
    }
    if (GetLocationType(mouse.x,mouse.y) == eLocationHotspot) {
      Hotspot *HP = Hotspot.GetAtScreenXY(mouse.x ,  mouse.y);
      mode_complementaire_defaut = HP.GetTextProperty("defaction");
    }
    if (GetLocationType(mouse.x,mouse.y) == eLocationObject) {
      Object *OB = Object.GetAtScreenXY(mouse.x, mouse.y);
      mode_complementaire_defaut = OB.GetTextProperty("defaction");
    }
    if (GetLocationType(mouse.x,mouse.y) == eLocationCharacter) {
      Character *CH = Character.GetAtScreenXY(mouse.x,  mouse.y);
      mode_complementaire_defaut = CH.GetTextProperty("defaction");
    }

    if (mode_complementaire_defaut == "") {
      mode_defaut = eModeWalkto;
      btDonner.NormalGraphic = 27;
      btOuvrir.NormalGraphic = 28;
      btFermer.NormalGraphic = 29;
      btPrendre.NormalGraphic = 30;
      btParler.NormalGraphic = 31;
      btRegarder.NormalGraphic = 32;
      btUtiliser.NormalGraphic = 33;
      btPousser.NormalGraphic = 34;
      btTirer.NormalGraphic = 35;
    }

    if (mode_complementaire_defaut == "DONNER") {
      mode_defaut = eModeCustom;
      btDonner.NormalGraphic = 27 + 9;
      btOuvrir.NormalGraphic = 28;
      btFermer.NormalGraphic = 29;
      btPrendre.NormalGraphic = 30;
      btParler.NormalGraphic = 31;
      btRegarder.NormalGraphic = 32;
      btUtiliser.NormalGraphic = 33;
      btPousser.NormalGraphic = 34;
      btTirer.NormalGraphic = 35;
    }

    if (mode_complementaire_defaut == "OUVRIR") {
      mode_defaut = eModeCustom;
      btDonner.NormalGraphic = 27;
      btOuvrir.NormalGraphic = 28 + 9;
      btFermer.NormalGraphic = 29;
      btPrendre.NormalGraphic = 30;
      btParler.NormalGraphic = 31;
      btRegarder.NormalGraphic = 32;
      btUtiliser.NormalGraphic = 33;
      btPousser.NormalGraphic = 34;
      btTirer.NormalGraphic = 35;
    }

    if (mode_complementaire_defaut == "FERMER") {
      mode_defaut = eModeCustom;
      btDonner.NormalGraphic = 27;
      btOuvrir.NormalGraphic = 28;
      btFermer.NormalGraphic = 29 + 9;
      btPrendre.NormalGraphic = 30;
      btParler.NormalGraphic = 31;
      btRegarder.NormalGraphic = 32;
      btUtiliser.NormalGraphic = 33;
      btPousser.NormalGraphic = 34;
      btTirer.NormalGraphic = 35;
    }

    if (mode_complementaire_defaut == "PRENDRE") {
      mode_defaut = eModePickup;
      btDonner.NormalGraphic = 27;
      btOuvrir.NormalGraphic = 28;
      btFermer.NormalGraphic = 29;
      btPrendre.NormalGraphic = 30 + 9;
      btParler.NormalGraphic = 31;
      btRegarder.NormalGraphic = 32;
      btUtiliser.NormalGraphic = 33;
      btPousser.NormalGraphic = 34;
      btTirer.NormalGraphic = 35;
    }

    if (mode_complementaire_defaut == "PARLER") {
      mode_defaut = eModeTalkto;
      btDonner.NormalGraphic = 27;
      btOuvrir.NormalGraphic = 28;
      btFermer.NormalGraphic = 29;
      btPrendre.NormalGraphic = 30;
      btParler.NormalGraphic = 31 + 9;
      btRegarder.NormalGraphic = 32;
      btUtiliser.NormalGraphic = 33;
      btPousser.NormalGraphic = 34;
      btTirer.NormalGraphic = 35;
    }

    if (mode_complementaire_defaut == "REGARDER") {
      mode_defaut = eModeLookat;
      btDonner.NormalGraphic = 27;
      btOuvrir.NormalGraphic = 28;
      btFermer.NormalGraphic = 29;
      btPrendre.NormalGraphic = 30;
      btParler.NormalGraphic = 31;
      btRegarder.NormalGraphic = 32 + 9;
      btUtiliser.NormalGraphic = 33;
      btPousser.NormalGraphic = 34;
      btTirer.NormalGraphic = 35;
    }

    if (mode_complementaire_defaut == "UTILISER") {
      mode_defaut = eModeInteract;
      btDonner.NormalGraphic = 27;
      btOuvrir.NormalGraphic = 28;
      btFermer.NormalGraphic = 29;
      btPrendre.NormalGraphic = 30;
      btParler.NormalGraphic = 31;
      btRegarder.NormalGraphic = 32;
      btUtiliser.NormalGraphic = 33 + 9;
      btPousser.NormalGraphic = 34;
      btTirer.NormalGraphic = 35;
    }

    if (mode_complementaire_defaut == "POUSSER") {
      mode_defaut = eModeCustom;
      btDonner.NormalGraphic = 27;
      btOuvrir.NormalGraphic = 28;
      btFermer.NormalGraphic = 29;
      btPrendre.NormalGraphic = 30;
      btParler.NormalGraphic = 31;
      btRegarder.NormalGraphic = 32;
      btUtiliser.NormalGraphic = 33;
      btPousser.NormalGraphic = 34 + 9;
      btTirer.NormalGraphic = 35;
    }

    if (mode_complementaire_defaut == "TIRER") {
      mode_defaut = eModeCustom;
      btDonner.NormalGraphic = 27;
      btOuvrir.NormalGraphic = 28;
      btFermer.NormalGraphic = 29;
      btPrendre.NormalGraphic = 30;
      btParler.NormalGraphic = 31;
      btRegarder.NormalGraphic = 32;
      btUtiliser.NormalGraphic = 33;
      btPousser.NormalGraphic = 34;
      btTirer.NormalGraphic = 35 + 9;
    }

  }



  if (inventaire.TopItem > 0) {
    btInvUp.NormalGraphic =  59;
    btInvUp.MouseOverGraphic = 60;
    btInvUp.Enabled = true;
  } else {
    btInvUp.NormalGraphic =  58;
    btInvUp.MouseOverGraphic = 58;
    btInvUp.Enabled = false;
  }

  if ((inventaire.ItemCount - inventaire.TopItem) > (inventaire.RowCount * inventaire.ItemsPerRow)) {
    btInvDown.NormalGraphic = 56;
    btInvDown.MouseOverGraphic = 57;
  btInvDown.Enabled = true;
  } else {
    btInvDown.NormalGraphic = 55;
    btInvDown.MouseOverGraphic = 55;
  btInvDown.Enabled = false;
  }
}
Title: Re: Pb label text when changing room
Post by: Khris on Sun 29/08/2010 23:57:27
Take a look at this part:

  buffer_objet = Game.GetLocationName(mouse.x , mouse.y );
  if (buffer_action != null) {
    buffer_action = buffer_action.Append(buffer_objet);
    lblHS.TextColor = COULEUR_TEXTE_NORMAL;
  lblHS.Text = buffer_action;
    if (mouse.Mode != eModeUseinv) inventaire_action = buffer_action;
  }


What happens is this: you're using a mouse mode that isn't supposed to be used with this template. Thus buffer_action is never set or cleared as soon as the mouse mode is active, and the third line in the code snippet above keeps appending the hotspot's name to the string (buffer_action).
Title: Re: Pb label text when changing room
Post by: Benjiman33 on Mon 30/08/2010 20:25:43
Thanks Khris, you're right I realized that mode_complementaire was null and thus buffer_action was never cleared.
I have created a new mouse.mode (eModeMap) that I call when I enter in the Map room and I added in the repeatdly execute fctn: 
if(mouse.Mode==eModeMap) {buffer_action=null;}

the problem is almost solved !
Almost cause when I change room, I have to click one time before I can make a move. Like if everything was block and the game was expecting the end of an action. When I click anywhere else My label text resets and everything become fine again...
Title: Re: Pb label text when changing room
Post by: Benjiman33 on Mon 30/08/2010 20:57:23
Ok Solved !! Even if I had set mouse.Mode=0 in room_leave function, the value was 1 when I changed the room... (don't know why) I just set it equals to 0 in the load function of the room and everything is fine now !!
Thanks Khris for debugging me at the beginning, it also helped me to solve my second problem ;)

Byee
Title: Re: Pb label text when changing room **SOLVED**
Post by: Khris on Mon 30/08/2010 22:40:05
Cool, and good luck with your game :)