Using more than 1 "on_event" function

Started by FrozenMonkey86, Tue 01/04/2014 00:43:10

Previous topic - Next topic

FrozenMonkey86

Hi,

I'm pretty new to scripting and I'm trying to use 2 "on_event" functions in my global script. I've been searching the online help guides and forum posts for most of the day and can't find the answer I'm looking for. I've tried playing around with the function names and variables and nesting the two functions inside each other but nothing seems to work. Anyway, my first on_event returns the mouse pointer to the interact icon after two items have been combined in the inventory (it previously defaulted to WalkTo mode) - This one works fine. My second is to close the inventory screen with a right mouse-click (obviously AGS comes back with on_event already defined).

Code: ags

function on_event(int event, int data) 
{
  if (event == eEventLoseInventory) { //loseInventory
    if ((gInventory.Visible==true) && (mouse.Mode == eModeWalkto)){
        Mouse.Mode=eModeInteract;
        
    }
  }
}

function on_event(int event, int data);
{
  if ((event == eEventGUIMouseDown) && (mouse.IsButtonDown==eMouseRight)){
  gInventory.Visible=false;
  }
}


I know that it makes no sense to have two identically named on_event functions, but I thought it would make it easier to explain what I'm trying to do. Any help would be greatly appreciated!

Thanks,

Ryan Timothy B

Code: ags
function on_event(int event, int data) 
{
  if (event == eEventLoseInventory) { //loseInventory
    if ((gInventory.Visible==true) && (mouse.Mode == eModeWalkto)){
        Mouse.Mode=eModeInteract;
    }
  } else if ((event == eEventGUIMouseDown) && (mouse.IsButtonDown==eMouseRight)){
    gInventory.Visible=false;
  }
}


SMF spam blocked by CleanTalk