Character functions repeat twice for some reason?

Started by gracefully-gauche, Fri 27/04/2018 01:30:07

Previous topic - Next topic

gracefully-gauche

Hey. I'm new to AGS and am still figuring my way out around it. For some reason, certain character functions (e.g. "Look" or "Interact") are looping and playing twice after the interaction occurs. I looked through my code to see if I'd accidentally entered it twice, but it was fine. I looked through my Global Script too, but nothing there either (none of the hotspot interactions are in there). I'm not really sure why it's doing this.

Here's the code from the problematic room:
Code: ags


function hCalendar_Look()
{
    cJessie.Say("It's November 2017.");
}

function hCalendar_Interact()
{
    cJessie.Say("I don't need that.");
}

function hPictureFrames_Look()
{
    cJessie.Say("8 Pictures that Mom framed for me last year.");
}

function hPictureFrames_Interact()
{
    cJessie.Say("I don't need that.");
}

function hJessieClock_Look()
{
    cJessie.Say("It's 3:17 PM.");
}

function hJessieClock_Interact()
{
    cJessie.Say("I don't need that.");
}

function hJessieWindow_Interact()
{
   cJessie.Say("I can't remove the window from the wall.");
}

function hJessieWindow_Look()
{
    cJessie.Say("It's a really nice day outside.");
}

function o8Ball_Interact()
{
    cJessie.Say("There it is!");
    cJessie.Walk(53, 71, eBlock, eWalkableAreas);
    cJessie.AddInventory(i8Ball);
    o8Ball.Visible = false;
    cJessie.Say("Let's ask it where Gigi is.");
}

function o8Ball_Look()
{
    cJessie.Say("My Magic 8-Ball.");
}

function region1_WalksOnto()
{
    cJessie.ChangeRoom(2, 17, 91);
}

function room_AfterFadeIn()
{
    cJessie.Say("Hey there. I'm Jessie. I'm looking for my friend Gigi.");
    cJessie.Say("We were playing hide and seek, and I'm having trouble finding her.");
    cJessie.Say("I think she might be in the basement.");
    cJessie.Say("We should ask the Magic 8-Ball where she is.");
    Display("Look for the Magic 8-Ball.");
}



Thanks!

Crimson Wizard

Could you show the code that runs player interaction? Probably it's in a on_mouse_click function somewhere in the GlobalScript.
Also, could you tell what template you are using, and if you are using any script modules created by other people?

gracefully-gauche

Code: ags
Hey, thanks for responding! I'm using the Default template.
Is this what you're referring to?
[code = ags]
function on_mouse_click(MouseButton button)
{
  if (button == eMouseLeft) 
  {
    Room.ProcessClick(mouse.x,mouse.y, mouse.Mode);
  }
  if (button == eMouseLeftInv)
  {
    Room.ProcessClick(mouse.x,mouse.y, mouse.Mode);
  }
  if (IsGamePaused() == 1) {
    // Game is paused, so do nothing (ie. don't allow mouse click)
  }
  else if (button == eMouseLeft) {
    Room.ProcessClick(mouse.x, mouse.y, mouse.Mode );
  }
  else if (button == eMouseRight || button == eMouseWheelSouth){
    // right-click our mouse-wheel down, so cycle cursor
    mouse.SelectNextMode();
  }
  else if (button == eMouseMiddle) { 
    // Middle-button-click, default make character walk to clicked area (a little shortcut)
    // Could have been just "player.Walk(mouse.x,mouse.y)", but it's best to
    // leave our options open - what if you have a special script triggered
    // on "walking" mode?
    Room.ProcessClick(mouse.x, mouse.y, eModeWalkto); 
  }
  else if (button == eMouseWheelNorth) { 
    // Mouse-wheel up, cycle cursors 
    // If mode isn't WALK, set the previous mode (notice usage of numbers instead
    // of eNums, when it suits us)...
    if (mouse.Mode>0) mouse.Mode=mouse.Mode-1; 
    else 
    { 
      // ...but if it is WALK mode...
      if (player.ActiveInventory!=null) 
      {
        //...and the player has a selected inventory item, set mouse mode to UseInv. 
        mouse.Mode=eModeUseinv; 
      }
      else 
      {
        // If they don't, however, just set it to mode TALK (change this line if you add more cursor modes)
        mouse.Mode=eModeTalkto; 
      }
    }
  }
}

Crimson Wizard

Yes, you have two blocks with same condition "if (button == eMouseLeft)".

Simply scroll a bit down, find and remove the second case. (It's after "if (IsGamePaused() == 1)")


Khris

Lines 6-13 should be removed; it looks like you added them without really understanding what the rest of the function is doing.

SMF spam blocked by CleanTalk