MI-9 Dialog not Activating When Doing Look At on an Item

Started by Ewery1, Mon 30/12/2013 23:05:53

Previous topic - Next topic

Ewery1

Okay, so this might be a more simple question, but it is about MI-9 so I figured it would be best to post it here. This contains multiple script which could have the problem, so bear with me. I have created a dialog called dBook ((You can find it below)) and when you have the item "Large Marine Life" (iBook), it should play dBook. However, it plays nothing. I have no idea what part of the script this is a fault of, so I will give the global script, the gui script, and the dialog (although I don't think it's the dialog's fault). Here you go:

Global script book part:
Code: ags
function iBook_OtherClick()
{
  if (UsedAction(eGA_LookAt)) {
    dBook.Start();
  }
  else Unhandled();
}


The gui script (Part where I may have gone wrong):
Code: ags
function on_mouse_click(MouseButton button) {
  
  if (!is_gui_disabled()) {
    int mrx=mouse.x+GetViewportX();
    int mry=mouse.y+GetViewportY();
    int x=mouse.x;
    int y=mouse.y;
    // get location under mouse cursor
    GSloctype=GetLocationType(x, y);
    GSlocname=Game.GetLocationName(x, y);
    GSagsusedmode=Mouse.Mode;
    used_action=global_action;
    
    InventoryItem*ii = InventoryItem.GetAtScreenXY(x, y);
    if (GSloctype==eLocationHotspot) {
      Hotspot*h=Hotspot.GetAtScreenXY(x, y);
      GSlocid=h.ID;
      
    }
    else if (GSloctype==eLocationCharacter) {
      Character*c=Character.GetAtScreenXY(x, y);
      GSlocid=c.ID;
    }
    else if (GSloctype==eLocationObject) {
      Object*o=Object.GetAtScreenXY(x, y);
      GSlocid=o.ID;
    }
    else if (ii!=null) GSlocid=ii.ID;
    
    
    
    
    if (IsGamePaused()) {
      // Game is paused, so do nothing (ie. don't allow mouse click)
    }
    // Mousebutton Left
    else if (button==eMouseLeft) 
    {
        
      if (GlobalCondition(2) || GlobalCondition(3) || GlobalCondition(4)) {
        // Do nothing, if:
        // the mode is useinv and the mouse is over the active inv (like "use knife on knife")
        // or the mode is talk, or "Give", and the mouse isnt over a character
        // or its GIVE and the mouse isnt over a inv.item

      }
      else if (ExtensionEx(1, GSlocname)=='e') {
        UpdateActionBar();
        ActionLine.TextColor=ActionLabelColorHighlighted;
        WalkOffScreen();
      }
      // walk to
      else if (GSagsusedmode==eModeUsermode2) {
        ActionLine.TextColor=ActionLabelColorHighlighted;
        if (IsInteractionAvailable(x, y, GSagsusedmode)) ProcessClick (x, y, GSagsusedmode);
        else ProcessClick(x, y, eModeWalkto);
      }   
      // talkto
      else if (GSagsusedmode==eModeTalkto && IsInteractionAvailable(x, y, GSagsusedmode) && GSloctype==eLocationCharacter) {
        ActionLine.TextColor=ActionLabelColorHighlighted;
        if (GoToCharacter(character[GSlocid], eDir_None, NPC_facing_player, 1)) character[GSlocid].RunInteraction(GSagsusedmode);
        SetAction(eMA_Default);
      }
      // Giveto
      else if ((GSagsusedmode == eModeUseinv) && GSloctype==eLocationCharacter && isAction(eGA_GiveTo)) {
        ActionLine.TextColor=ActionLabelColorHighlighted;
        ItemGiven=player.ActiveInventory;
        
        if (GoToCharacter(character[GSlocid], eDir_None, NPC_facing_player, 2)) {
          if (IsInteractionAvailable (mrx - GetViewportX (), mry - GetViewportY (), eModeUseinv) == 1) {
            character[GSlocid].RunInteraction(eModeUseinv);        
          }
        }
        SetAction (eMA_Default);
      }     
      else {
        UpdateActionBar();
        ActionLine.TextColor=ActionLabelColorHighlighted;
        ProcessClick(x, y, GSagsusedmode);
        SetAction(eMA_Default);
        ItemGiven=null;
      }
    }
    // Mousebutton Right
    else if (button==eMouseRight) {
      if (alternative_action==eMA_Default) {
        SetAction(eMA_Default);
        ActionLine.TextColor=ActionLabelColorHighlighted;
        if (Mouse.Mode==eModeUsermode2) {
          if (ExtensionEx(1, GSlocname)=='e') {
            UpdateActionBar();
            ActionLine.TextColor=ActionLabelColorHighlighted;
            WalkOffScreen();
          }          
          else ProcessClick(x, y, eModeWalkto);
        }
        else ProcessClick(x, y, Mouse.Mode);
      }
      else
      {
        SetAction(alternative_action);
        used_action=global_action;
        UpdateActionBar();
        ActionLine.TextColor=ActionLabelColorHighlighted;
        GSagsusedmode=Mouse.Mode;
        if (GSagsusedmode==eModeTalkto && IsInteractionAvailable(x, y, GSagsusedmode) && GSloctype==eLocationCharacter) { //(GetCharacterAt (mouse.x, mouse.y) < 7))
          if (GoToCharacter(character[GSlocid], eDir_None, NPC_facing_player,2 )) character[GSlocid].RunInteraction(GSagsusedmode);
        }
        else ProcessClick(x, y, GSagsusedmode);
        SetAction(eMA_Default);
      }
    }
    //left click in inventory
    else if (button==eMouseLeftInv) {
      if (!isAction(eGA_GiveTo))ItemGiven= null;
   
      if (GlobalCondition (1)) {
        // if the mouse is in the inventory and modes Walk or pickup are selected
        SetAction (eGA_Use);
        location=GSinvloc;    
        if (Extension()=='u' && ii.IsInteractionAvailable(eModeInteract)) {
          // use it immediately (not with anything else)
          used_action=global_action;
          ii.RunInteraction(eModeInteract);
          SetAction(eMA_Default);
        }
        else {
          if (oldschool_inv_clicks) {
            SetAction (eGA_LookAt);
            used_action=global_action;
            ii.RunInteraction(eModeLookat);   
            SetAction(eMA_Default);
          }
          else player.ActiveInventory=ii;
        }
      } 
      else  if (GlobalCondition (2) == 1) {
        // if the mode is useinv and the mouse is over the active inv (like "use knife on knife")
        // so do nothing again
      }
      else {
        used_action=global_action;
        if (Mouse.Mode==eModeInteract) {
          if (isAction(eGA_Use) && ii.IsInteractionAvailable(eModeInteract)) {
            ActionLine.TextColor=ActionLabelColorHighlighted;
            ii.RunInteraction(eModeInteract);
            SetAction(eMA_Default);
          }
          else player.ActiveInventory=ii;
        }
        else {
          if ( (Mouse.Mode >0 && Mouse.Mode <10 )&& ii != null) {
                GSagsusedmode=Mouse.Mode;
                ActionLine.TextColor=ActionLabelColorHighlighted;
                ii.RunInteraction(Mouse.Mode);
                SetAction(eMA_Default);
          }
        }
      }
    }
    //right click in inventory
    else if (button==eMouseRightInv) {
      if (alternative_action==eMA_Default) {
        SetAction(eMA_Default);
      }
      else {
        SetAction(alternative_action);
        used_action=global_action;
        GSagsusedmode=Mouse.Mode;
        if (Mouse.Mode==eModeInteract) {
          if (isAction(eGA_Use) && ii.IsInteractionAvailable(eModeInteract)) {
            UpdateActionBar();
            ActionLine.TextColor=ActionLabelColorHighlighted;
            ii.RunInteraction(eModeInteract);
            SetAction(eMA_Default);
          }
          else player.ActiveInventory=ii;
        }
        else {
          UpdateActionBar();
          ActionLine.TextColor=ActionLabelColorHighlighted;
          SetAction(eMA_Default);
        }
      }
    }
  }
}

function repeatedly_execute_always() {
  // Doubleclick Timer
  if (!IsGamePaused() && !is_gui_disabled()) {
    if (timer_run == true)
    {
      timer_click++;
      if (timer_click >= dc_speed){
        timer_click = 0;
        timer_run = false;
      }
    }
  }
}


The dialog (Yes, it's strange):

// Dialog script file
@S 
Rachel: It's a book on Large Marine Life.// Dialog startup entry point
return
@1
Book: Whales are the largest mammals that inhabit the Earth, however, all of them are vastly different. The whale meat industry is large in Asia and brings them to the brink of extinction.
Rachel: That's what I do. Prevent them from becoming extinct by gathering data.
goto-dialog 1
@2
Book: Sharks are misunderstood carnivores which are at the top of the food chain in the ocean. However, poaching threatens to drive them to death.
Rachel: I don't much like sharks. Whales are more my thing.
goto-dialog 2
@3
Rachel: There doesn't appear to be anything else worth reading here.
stop

Khris

Here's the thing: the way the 9-verb GUI was written, when it comes to inventory items, it actually uses the look at event, not the other click event.
The simple solution, as explained in the PDF that comes with the template:
QuoteFor inventory items, it's a little bit different, because there is no any_click event in the room editor. So you first start
with "other click on inventory item", which creates the function iCup_OtherClick (in case you have an item, called
iCup).
Now copy this function name and paste it at other events, like Interact, look, talk and so on. In the end, you only have
one function name in all five events. You can also take a look at the sample items.

Ewery1

Quote from: Khris on Mon 30/12/2013 23:31:12
Here's the thing: the way the 9-verb GUI was written, when it comes to inventory items, it actually uses the look at event, not the other click event.
The simple solution, as explained in the PDF that comes with the template:
QuoteFor inventory items, it's a little bit different, because there is no any_click event in the room editor. So you first start
with "other click on inventory item", which creates the function iCup_OtherClick (in case you have an item, called
iCup).
Now copy this function name and paste it at other events, like Interact, look, talk and so on. In the end, you only have
one function name in all five events. You can also take a look at the sample items.

Oh okay whoops! Thanks for helping, didn't realize it was so simple :P.

SMF spam blocked by CleanTalk