MMM: Need help adding new Action Commands ;( still one problem

Started by Dr Fred Rubacant Edison, Sun 03/12/2006 09:01:17

Previous topic - Next topic
I just cant get it to work right  the Action is in the game gui but it dont work right

I  resize a few of the words on the Gui just to test it




The game script will still compile

The game will crash when i use this code that makes it crash: 

SetActionButtons (A_LOOKIN,  "a_button_lookin 9 29 30 Zz");  // what should this be set to

and it will  crash this this to SetAlternativeAction (location, 'j', A_LOOKIN);


Crash Warning:
Quote
Error: Run_text_script1: error -6 running  game start
Error: Array index out of bounds index 10.9)

Code: ags

// SCRIPT HEADER


// --- action ---
#define A_SWITCH_TO -2
#define A_DEFAULT   -1
#define A_WALK_TO    0
#define A_LOOK_AT    1
#define A_TALK_TO    2
#define A_GIVE_TO    3
#define A_PICK_UP    4
#define A_USE        5
#define A_OPEN       6
#define A_CLOSE      7
#define A_PUSH       8
#define A_PULL       9
#define A_COUNT_    10
#define A_LOOKIN    11  // NEW
#define A_USE_INV   -3
#define A_HELP      -4



// GLOBAL SCRIPT




//Action Functions  

function TranslateAction (string result, int action, string objects, 
string item){
  // get translated action template
  if (action == A_WALK_TO)   StrCopy (result, "Walk to %s");
  else if (action == A_LOOK_AT)   StrCopy (result, "Look at %s");
  

  else if (action == A_LOOKIN)   StrCopy (result, "Look in %s");  // NEW
  

  else if (action == A_TALK_TO)   StrCopy (result, "Talk To %s");
  else if (action == A_GIVE_TO)
  {
    if (StrLen (item) > 0)        StrCopy (result, "Give !s to  %s");
    else                          StrCopy (result, "Give To %s");
  }
  else if (action == A_PICK_UP)   StrCopy (result, "Pick Up %s");
  else if (action == A_USE)
  {
    if (StrLen (item) > 0)        StrCopy (result, "Use !s with %s");
    else                          StrCopy (result, "Use %s");
  }
  else if (action == A_OPEN)      StrCopy (result, "Open %s");
  else if (action == A_CLOSE)     StrCopy (result, "Close %s");
  else if (action == A_PUSH)      StrCopy (result, "Push %s");
  else if (action == A_PULL)      StrCopy (result, "Pull %s");
  else if (action == A_SWITCH_TO) StrCopy (result, "Switch To %s");
  // fill object and item into action template
  StrCopy (result, GetTranslation (result));
  int ip = StrContains (result, "!s");
  if (ip >= 0)
  {
    int op = StrContains (result, "%s");
    StrSetCharAt (result, ip, '%');
    if (ip < op) StrFormat (result, result, item, objects);
    else         StrFormat (result, result, objects, item);
  }
  else           StrFormat (result, result, objects);
}

function isAction (int test_action){
  return global_action == test_action;
}

function UsedAction (int test_action){
  return ((used_action == test_action) && (GSagsusedmode != 
MODE_USEINV)) || ((test_action == A_USE_INV) && (used_action == A_USE) 
&& (GSagsusedmode == MODE_USEINV));
}

function SetAction (int new_action){
  // set default action
  if (new_action == A_DEFAULT)      new_action = default_action;
  // set corresponding cursormode
  if (new_action == A_WALK_TO)       SetCursorMode (9);
  else if (new_action == A_LOOK_AT)  SetCursorMode (1);
  
  
  
  else if (new_action == A_TALK_TO)  SetCursorMode (3);
  else if (new_action == A_GIVE_TO)  SetCursorMode (2);
  else if (new_action == A_PICK_UP)  SetCursorMode (5);
  else if (new_action == A_USE)      SetCursorMode (2);
  else if (new_action == A_OPEN)     SetCursorMode (8);
  else if (new_action == A_CLOSE)    SetCursorMode (8);
  else if (new_action == A_PUSH)     SetCursorMode (8);
  else if (new_action == A_PULL)     SetCursorMode (8);
  else if (new_action == A_LOOKIN)   SetCursorMode (1);  // NEW

// save action
  global_action = new_action;
}

function SetDefaultAction (int def_action){
  default_action = def_action;
  SetAction (A_DEFAULT);
}




// ============================= GlobalCondition ===========================================

   // Dont know what to put here if i need to

function GlobalCondition (int parameter){
  // here are some conditions that are used many times in the script
  int cond;
  if (parameter == 1)
  {
    // if the mouse is in the inventory and modes Walk or pickup are selected
    cond = ((GetInvAt (mouse.x, mouse.y) >= 0)    &&     (isAction 
(A_WALK_TO) || isAction (A_PICK_UP)));
  }
  else if (parameter == 2)
  {
    // if the mode is useinv and the mouse is over the active inv (like "use knife on knife")
    cond = ((character [GetPlayerCharacter ()].activeinv == GetInvAt 
(mouse.x, mouse.y)) && (GetCursorMode () == 4));
  }
  else if (parameter == 3)
  {
    // if the mode is talk, or "Give", and the mouse isnt over a character
    cond = ((isAction (A_TALK_TO) || (isAction (A_GIVE_TO) && 
(GetCursorMode () == 4))) && (GetLocationType (mouse.x, mouse.y) != 2));
  }
  else if (parameter == 4)
  {
    // if its  GIVE and the mouse isnt over a inv.item
    cond = ((GetCursorMode () == 2) && isAction (A_GIVE_TO) && (GetInvAt 
(mouse.x, mouse.y) < 0));
  }
  if (parameter == 5)
  {
    // if its over the "other characters" buttons in the inventory.
    cond = ((GetGUIAt (mouse.x, mouse.y) == MAINGUI) && ((GetGUIObjectAt 
(mouse.x, mouse.y) == 12) || (GetGUIObjectAt (mouse.x, mouse.y) == 13)));
  }
  return cond;
}



// This is under  Action


RemoveExtension (location);
    AddExtension ('l', location); // set default action "look at"
  }
  SetAlternativeAction (location, 'n', A_DEFAULT);
  SetAlternativeAction (location, 'g', A_GIVE_TO);
  SetAlternativeAction (location, 'p', A_PICK_UP);
  SetAlternativeAction (location, 'u', A_USE);
  SetAlternativeAction (location, 'o', A_OPEN);
  SetAlternativeAction (location, 'l', A_LOOK_AT);
  
  

  SetAlternativeAction (location, 's', A_PUSH);
  SetAlternativeAction (location, 'c', A_CLOSE);
  SetAlternativeAction (location, 't', A_TALK_TO);
  SetAlternativeAction (location, 'y', A_PULL);
  
//SetAlternativeAction (location, 'j', A_LOOKIN);  // Game will crash if used

RemoveExtension (location);
  StrCopy (SHOWNlocation, location);
}


//  Translation  // This makes GUI botton work   doing the  // on any other one's turns them off in the game  

 // --- translate GUI action buttons ---
  SetActionButtons (A_GIVE_TO, "a_button_give 0 1 2 Dd");
  SetActionButtons (A_PICK_UP, "a_button_pick_up 1 7 8 Ee");
  SetActionButtons (A_USE,     "a_button_use 2 13 14 Ww");
  
  SetActionButtons (A_OPEN,    "a_button_open 3 3 4 Aa");
  SetActionButtons (A_LOOK_AT, "a_button_look_at 4 9 10 Qq");
  SetActionButtons (A_PUSH,    "a_button_push 5 15 28 Xx");
  SetActionButtons (A_CLOSE,   "a_button_close 6 5 6 Ss");
  SetActionButtons (A_TALK_TO, "a_button_talk_to 7 11 12 Cc");
  SetActionButtons (A_PULL,    "a_button_pull 8 29 30 Zz");
  
 // SetActionButtons (A_LOOKIN,  "a_button_lookin 9 29 30 Zz");  // Game will crash if used Dont know //what to set it at



// Unhandled Event


if (UsedAction (A_CLOSE))
    {
      DisplaySpeech (GetPlayerCharacter (), "Did not work.");
    }
    else if (UsedAction (A_USE) && type >= 5)
    {
      //if inv on inv:
      DisplaySpeech (GetPlayerCharacter (), "Didnt work.");
    }
    else if (UsedAction (A_LOOK_AT))
    {
      if (GetGlobalInt(12)==0) { Display("Cool."); SetGlobalInt(12,1); }
      else if ( GetGlobalInt(12)==1) { DisplaySpeech 
(GetPlayerCharacter(), "ok."); 
SetGlobalInt(12,2); }
      else if ( GetGlobalInt(12)==2) { DisplaySpeech 
(GetPlayerCharacter(), "Dude."); SetGlobalInt(12,3); }
      else if ( GetGlobalInt(12)==3) { DisplaySpeech 
(GetPlayerCharacter(), "Its Cool."); 
SetGlobalInt(12,0); }
    }
    else if ((UsedAction (A_PUSH)) || (UsedAction (A_PULL)))
    {
      DisplaySpeech (GetPlayerCharacter(), "Take that.");
    }
   
     else if (UsedAction (A_PICK_UP))
    {
      DisplaySpeech (GetPlayerCharacter(), "Cant pick that up.");
    }
    
    else if (UsedAction (A_LOOKIN))  // NEW
    {
      DisplaySpeech (GetPlayerCharacter(), "Nothing inside it.");  // NEW
    }



    else if (UsedAction (A_OPEN))
    {
      DisplaySpeech (GetPlayerCharacter(), "Cant open it.");
    }
    else if (UsedAction (A_TALK_TO))
    {
      if (type == 2)
      {
        DisplaySpeech (GetPlayerCharacter (), "Ich habe nichts zu sagen.");
      }
      else DisplaySpeech (GetPlayerCharacter (), "Das klappt so nicht.");
    }
    else if (type == 4)
    {
      DisplaySpeech (GetPlayerCharacter (), "Das klappt so nicht.");
    }
    else if (UsedAction (A_USE) || UsedAction (A_USE_INV))
    {
      //  else if (UsedAction(A_USE)) {
      DisplaySpeech (GetPlayerCharacter (), "Didnt work.");
    }
    ////////////////////////////////////////////////////
  }
}
Some say i need panels! and Some say i dont Need them.   WHERES THE DRUGS I'm going CRAZY. Plus I must have been on Drugs and a Maniac if i was going to name the game Maniacs Mansion.

What was i thinking!!!!!

SSH

Rubacant, my guess is that you didn't increase the size of some array somewhere when you added an extra verb. However, why do you think we will know what these functions you are calling do if you don't post their code? You seem to have posted nearly all your globals script EXCEPT the function that crashes...
12

#2
This is what crashed:

Code: ags

// This is under  Action


RemoveExtension (location);
    AddExtension ('l', location); // set default action "look at"
  }
  SetAlternativeAction (location, 'n', A_DEFAULT);
  SetAlternativeAction (location, 'g', A_GIVE_TO);
  SetAlternativeAction (location, 'p', A_PICK_UP);
  SetAlternativeAction (location, 'u', A_USE);
  SetAlternativeAction (location, 'o', A_OPEN);
  SetAlternativeAction (location, 'l', A_LOOK_AT);
 
 

  SetAlternativeAction (location, 's', A_PUSH);
  SetAlternativeAction (location, 'c', A_CLOSE);
  SetAlternativeAction (location, 't', A_TALK_TO);
  SetAlternativeAction (location, 'y', A_PULL);
 
//SetAlternativeAction (location, 'j', A_LOOKIN);  // Game will crash if used

RemoveExtension (location);
  StrCopy (SHOWNlocation, location);
}


//  Translation  // This makes GUI botton work   doing the  // on any other one's turns them off in the game 

 // --- translate GUI action buttons ---
  SetActionButtons (A_GIVE_TO, "a_button_give 0 1 2 Dd");
  SetActionButtons (A_PICK_UP, "a_button_pick_up 1 7 8 Ee");
  SetActionButtons (A_USE,     "a_button_use 2 13 14 Ww");
 
  SetActionButtons (A_OPEN,    "a_button_open 3 3 4 Aa");
  SetActionButtons (A_LOOK_AT, "a_button_look_at 4 9 10 Qq");
  SetActionButtons (A_PUSH,    "a_button_push 5 15 28 Xx");
  SetActionButtons (A_CLOSE,   "a_button_close 6 5 6 Ss");
  SetActionButtons (A_TALK_TO, "a_button_talk_to 7 11 12 Cc");
  SetActionButtons (A_PULL,    "a_button_pull 8 29 30 Zz");
 
 // SetActionButtons (A_LOOKIN,  "a_button_lookin 9 29 30 Zz");  // Game will crash if used Dont know //what to set it at
Some say i need panels! and Some say i dont Need them.   WHERES THE DRUGS I'm going CRAZY. Plus I must have been on Drugs and a Maniac if i was going to name the game Maniacs Mansion.

What was i thinking!!!!!

SSH

No, its not. It crashes inside SetAlternativeAction. You still haven't posted that function's code. But to fix your problem, search your global script for [11] and change it to [12] (or it may be [10] or [9] you need to change to [12], but its some array taht is dfined as too small.
12

#4
Code: ags

function SetAlternativeAction (string location, char extension, int 
alt_action){
  if (alt_action == A_DEFAULT)
  {
    if (Extension (location) == extension)
    {
      alternative_action = alt_action;
    }
  }
  else
  {
    int button = action_button [alt_action];
    int normalbuttonpic = action_button_normal [alt_action];
    int overbuttonpic = action_button_highlight [alt_action];
    // used for setting the default action given the extension.
    if (Extension (location) == extension)
    {
      SetButtonPic (MAINGUI, button, 1, overbuttonpic);
      alternative_action = alt_action;
    }
    else
    {
      SetButtonPic (MAINGUI, button, 1, normalbuttonpic);
    }
    SetButtonPic (MAINGUI, button, 2, overbuttonpic);
  }
}

function OpenCloseExtension (int gi, string location){
  if ((GetGlobalInt (gi) == 0) || (GetGlobalInt (gi) == 2)) AddExtension 
('o', location);
  else                                                      AddExtension 
('c', location);
}

function VariableExtensions (string location){
  // put here wich extension will show the things with variable extension (>v)
  int are = character [GetPlayerCharacter ()].room;
  int o = GetObjectAt (mouse.x, mouse.y);
  int h = GetHotspotAt (mouse.x, mouse.y);

       if ((are == 1) && (h == 1)) OpenCloseExtension (3, location);
  else if ((are == 2) && (h == 1)) OpenCloseExtension (3, location);
  else if ((are == 2) && (h == 2)) OpenCloseExtension (4, location);
  else if ((are == 3) && (h == 1)) OpenCloseExtension (4, location);
  else if ((are == 3) && (h == 2)) OpenCloseExtension (5, location);
  else if ((are == 4) && (h == 1)) OpenCloseExtension (5, location);
  else if ((are == 3) && (h == 3)) OpenCloseExtension (6, location);
  else if ((are == 6) && (h == 6)) OpenCloseExtension (6, location);
  else if ((are == 7) && (h == 1)) OpenCloseExtension (7, location);
  else if ((are == 8) && (h == 1)) OpenCloseExtension (7, location);


}

function CheckDefaultAction (){
  // you could want to change which extension activates which default action, or which button sprite
  // it changes. The extensions are characters, so remember to put them with single ', not ".
  string location;
  GetLocationName (mouse.x, mouse.y, location);
  if (Extension (location) == 0)
  {
    // Setting default modes if the thing has no extension:
    if (GetLocationType (mouse.x, mouse.y) == 2)
    {
      // if it is a character
      AddExtension ('t', location); // set default action "talk to"
    }
    else if ((GetLocationType (mouse.x, mouse.y) != 0) || (GetInvAt 
(mouse.x, mouse.y) >= 0))
    {
      // if its an inv item, a hotspot or an object
      AddExtension ('l', location); // set default action "look at"
    }
    else
    {
      AddExtension ('n', location); // set default action "none"
    }
  }
  else if (Extension (location) == 'v')
  {
    // if the default action deppends on some events
    RemoveExtension (location);
    VariableExtensions (location);
  }
  if (GlobalCondition (2) || GlobalCondition (3) || GlobalCondition (4))
  {
    StrCopy (location, ">n");//Dont send the name of the hotspt/obj/char/inv to the action bar and set default action "none"
  }
  StrCopy (GSinvloc, location);
  if ((Extension (location) == 'u') && (GetInvAt (mouse.x, mouse.y) >= 0))
  {
    // it's an inv item
    RemoveExtension (location);
    AddExtension ('l', location); // set default action "look at"
  }
  SetAlternativeAction (location, 'n', A_DEFAULT);
  SetAlternativeAction (location, 'g', A_GIVE_TO);
  SetAlternativeAction (location, 'p', A_PICK_UP);
  SetAlternativeAction (location, 'u', A_USE);
  SetAlternativeAction (location, 'o', A_OPEN);
  SetAlternativeAction (location, 'l', A_LOOK_AT);
  
  

  SetAlternativeAction (location, 's', A_PUSH);
  SetAlternativeAction (location, 'c', A_CLOSE);
  SetAlternativeAction (location, 't', A_TALK_TO);
  SetAlternativeAction (location, 'y', A_PULL);
  
//SetAlternativeAction (location, 'j', A_LOOKIN);

RemoveExtension (location);
  StrCopy (SHOWNlocation, location);
}
Some say i need panels! and Some say i dont Need them.   WHERES THE DRUGS I'm going CRAZY. Plus I must have been on Drugs and a Maniac if i was going to name the game Maniacs Mansion.

What was i thinking!!!!!

Ashen

#5
I think the problem comes from these lines:
Code: ags

    int button = action_button [alt_action];
    int normalbuttonpic = action_button_normal [alt_action];
    int overbuttonpic = action_button_highlight [alt_action];


Based on these lines, around 117 in the Global Script:
Code: ags

int action_button [A_COUNT_];
int action_button_normal [A_COUNT_];
int action_button_highlight [A_COUNT_];
int action_l_keycode [A_COUNT_];
int action_u_keycode [A_COUNT_];


Those arrays are set based on the A_COUNT_ define in the Script Header (the line above your new #define A_LOOKIN 11 line) so upping that value should solve the error. You could define A_LOOKIN as 10 and change A_COUNT_ to 11 (I guess you only made it 11 because A_COUNT_ was 10?) :
Code: ags

// SCRIPT HEADER


// --- action ---
#define A_SWITCH_TO -2
#define A_DEFAULT   -1
#define A_WALK_TO    0
#define A_LOOK_AT    1
#define A_TALK_TO    2
#define A_GIVE_TO    3
#define A_PICK_UP    4
#define A_USE        5
#define A_OPEN       6
#define A_CLOSE      7
#define A_PUSH       8
#define A_PULL       9
#define A_LOOKIN    10  // NEW
#define A_COUNT_    11
#define A_USE_INV   -3
#define A_HELP      -4


EDIT:
Since you've added buttons to the GUI, you'll need to change the line:
Code: ags

int button_action [9];


(Just after the array declarations) to reflect how many buttons you now have. You'll also probably also need to re-arreng the GUI (if you  haven't already) so that the new button is control 10 (currently the 'Up' arrow for the inventory). Otherwise, you're likely to get more errors like this later in the script.
I know what you're thinking ... Don't think that.

#6


Still have one little Problem :(

I need help adding a new SetCursorMode  like SetCursorMode (10)

When i use SetCursorMode (10) the game will crash when i click on Look in

Quote
Error set cursor mode:
Invalid cursor mode specified

line 195
line 1637

If i use  SetCursorMode (1)  Any thing thats not set to   if (UsedAction (A_LOOK_IN)) {    and set to    if (UsedAction (A_LOOK_AT)) {

when i do look in action  on a plant it saids its a plant if its not set up to use if (UsedAction (A_LOOK_IN)) {


Heres Code:

Code: ags

// ============================= action functions //===========================================
int global_action;
int default_action;
int alternative_action;
int used_action;
int action_button [A_COUNT_];
int action_button_normal [A_COUNT_];
int action_button_highlight [A_COUNT_];
int action_l_keycode [A_COUNT_];
int action_u_keycode [A_COUNT_];


int button_action [15];


function TranslateAction (string result, int action, string objects, 
string item){
  // get translated action template
  if (action == A_WALK_TO)   StrCopy (result, "Walk to %s");
  else if (action == A_LOOK_AT)   StrCopy (result, "Look at %s");
   else if (action == A_LOOK_IN)   StrCopy (result, "Look in %s");  // NEW

  else if (action == A_TALK_TO)   StrCopy (result, "Talk To %s");
  else if (action == A_GIVE_TO)
  {
    if (StrLen (item) > 0)        StrCopy (result, "Give !s to  %s");
    else                          StrCopy (result, "Give To %s");
  }
  else if (action == A_PICK_UP)   StrCopy (result, "Pick Up %s");
  else if (action == A_USE)
  {
    if (StrLen (item) > 0)        StrCopy (result, "Use !s with %s");
    else                          StrCopy (result, "Use %s");
  }
  else if (action == A_OPEN)      StrCopy (result, "Open %s");
  else if (action == A_CLOSE)     StrCopy (result, "Close %s");
  else if (action == A_PUSH)      StrCopy (result, "Push %s");
  else if (action == A_PULL)      StrCopy (result, "Pull %s");
  else if (action == A_SWITCH_TO) StrCopy (result, "Switch To %s");
 

  // fill object and item into action template
  StrCopy (result, GetTranslation (result));
  int ip = StrContains (result, "!s");
  if (ip >= 0)
  {
    int op = StrContains (result, "%s");
    StrSetCharAt (result, ip, '%');
    if (ip < op) StrFormat (result, result, item, objects);
    else         StrFormat (result, result, objects, item);
  }
  else           StrFormat (result, result, objects);
}

function isAction (int test_action){
  return global_action == test_action;
}

function UsedAction (int test_action){
  return ((used_action == test_action) && (GSagsusedmode != 
MODE_USEINV)) || ((test_action == A_USE_INV) && (used_action == A_USE) 
&& (GSagsusedmode == MODE_USEINV));
}

function SetAction (int new_action){
  // set default action
  if (new_action == A_DEFAULT)      new_action = default_action;
  // set corresponding cursormode
  if (new_action == A_WALK_TO)       SetCursorMode (9);
  else if (new_action == A_LOOK_AT)  SetCursorMode (1);
   
  
  
  
  else if (new_action == A_TALK_TO)  SetCursorMode (3);
  else if (new_action == A_GIVE_TO)  SetCursorMode (2);
  else if (new_action == A_PICK_UP)  SetCursorMode (5);
  else if (new_action == A_USE)      SetCursorMode (2);
  else if (new_action == A_OPEN)     SetCursorMode (8);
  else if (new_action == A_CLOSE)    SetCursorMode (8);
  else if (new_action == A_PUSH)     SetCursorMode (8);
  else if (new_action == A_PULL)     SetCursorMode (8);
  else if (new_action == A_LOOK_IN)  SetCursorMode (1);  // Need to make new mode like 10  game //crash when i use 10 but if i use 1 it dose the thing that i was talking about.



// save action
  global_action = new_action;
}

function SetDefaultAction (int def_action){
  default_action = def_action;
  SetAction (A_DEFAULT);
}




// ============================= GlobalCondition //===========================================

function GlobalCondition (int parameter){
  // here are some conditions that are used many times in the script
  int cond;
  if (parameter == 1)
  {
    // if the mouse is in the inventory and modes Walk or pickup are selected
    cond = ((GetInvAt (mouse.x, mouse.y) >= 0)    &&     (isAction 
(A_WALK_TO) || isAction (A_PICK_UP)));
  }
  else if (parameter == 2)
  {
    // if the mode is useinv and the mouse is over the active inv (like "use knife on knife")
    cond = ((character [GetPlayerCharacter ()].activeinv == GetInvAt 
(mouse.x, mouse.y)) && (GetCursorMode () == 4));
  }
  else if (parameter == 3)
  {
    // if the mode is talk, or "Give", and the mouse isnt over a character
    cond = ((isAction (A_TALK_TO) || (isAction (A_GIVE_TO) && 
(GetCursorMode () == 4))) && (GetLocationType (mouse.x, mouse.y) != 2));
  }
  else if (parameter == 4)
  {
    // if its  GIVE and the mouse isnt over a inv.item
    cond = ((GetCursorMode () == 2) && isAction (A_GIVE_TO) && (GetInvAt 
(mouse.x, mouse.y) < 0));
  
 //}
 
// NEW  TRYED this but did not work
 // else if (parameter == 5)
 // {
    
  //  cond = ((GetCursorMode () == 10)  && isAction (A_LOOK_AT)   &&  (GetLocationType 
   // (mouse.x, mouse.y)  < 0)); // 

  
}
  if (parameter == 5)  // and changed that to 6
  {
    // if its over the "other characters" buttons in the inventory.
    cond = ((GetGUIAt (mouse.x, mouse.y) == MAINGUI) && ((GetGUIObjectAt 
(mouse.x, mouse.y) == 12) || (GetGUIObjectAt (mouse.x, mouse.y) == 13)));
  }
  return cond;
}





// ============================= ActionBar //===========================================

function UpdateActionBar (){
  // set the text in the action bar
  string madetext;
  int action = global_action;
  string objects;
  string item;
  StrCopy (objects, SHOWNlocation);
  StrCopy (item, "");
  if (GlobalCondition (5) == 1)
  {
    // write SWITCH TO CHAR
    action = A_SWITCH_TO;
    if (GetGUIObjectAt (mouse.x, mouse.y) == 12)
    {
    //  StrCopy (objects, character [GSotherplayerup].name);
    }
    else
    {
     // StrCopy (objects, character [GSotherplayerdown].name);
    }
  }
  else if (GetCursorMode () == 4)
  {
    // use or give inventory item
    GetInvName (character [GetPlayerCharacter ()].activeinv, item);
    RemoveExtension (item);
  }
  else if (GlobalCondition (1) == 1)
  {
    // if the mouse is in the inventory and modes Walk or pickup are selected
    action = A_USE;
  }
  TranslateAction (madetext, action, objects, item);
  // show action text
  SetLabelText (ACTION, 0, madetext);
  SetLabelColor (ACTION, 0, ActionLabelColorNormal);
}






// ============================= on_mouse_click ===========================================
// this section after GoToCharacter

#sectionstart on_mouse_click  // DO NOT EDIT OR REMOVE THIS LINE
function on_mouse_click (int button){
  // called when a mouse button is clicked. button is either LEFT or RIGHT
  int mrx = mouse.x + GetViewportX ();
  int mry = mouse.y + GetViewportY ();
  // get location under mouse cursor
  GSloctype = GetLocationType (mouse.x, mouse.y);
  if (GSloctype == 1) GSlocid = GetHotspotAt (mouse.x, mouse.y);
  else if (GSloctype == 2) GSlocid = GetCharacterAt (mouse.x, mouse.y);
  else if (GSloctype == 3) GSlocid = GetObjectAt (mouse.x, mouse.y);
  else if (GetInvAt (mouse.x, mouse.y) >= 0) GSlocid = GetInvAt 
(mouse.x, mouse.y);
  GetLocationName (mouse.x, mouse.y, GSlocname);
  GSagsusedmode = GetCursorMode ();
  used_action = global_action;
  if (IsGamePaused () == 1)
  {
    // Game is paused, so do nothing (ie. don't allow mouse click)
  }
  else if (IsGUIOn (MAPS) == 1)
  {
    // if map
    if (button == LEFT)
    {
      if (IsInteractionAvailable (mouse.x, mouse.y, MODE_USE)) 
ProcessClick (mouse.x, mouse.y, MODE_USE);
      else ProcessClick (mouse.x, mouse.y, MODE_WALK);
    }
  }
  //end if map
  else if (button == LEFT)
  {
    if (GlobalCondition (2) || GlobalCondition (3) || GlobalCondition (4))
    {
      // SetMode("default");
    }
    else if (GSagsusedmode == 9)
    {
      // walk to
      SetLabelColor (ACTION, 0, ActionLabelColorHighlighted);
      if (IsInteractionAvailable (mouse.x, mouse.y, GSagsusedmode)) 
ProcessClick (mrx - GetViewportX (), mry - GetViewportY (), GSagsusedmode);
      else ProcessClick (mrx - GetViewportX (), mry - GetViewportY (), 
MODE_WALK);
    }
    else if ((GSagsusedmode == MODE_TALK) && (IsInteractionAvailable 
(mouse.x, mouse.y, GSagsusedmode) == 1) && (GetCharacterAt (mouse.x, 
mouse.y) < 0))
    {
      SetLabelColor (ACTION, 0, ActionLabelColorHighlighted);
      if (GoToCharacter (GSlocid, 0, 1, 2)) RunCharacterInteraction 
(GSlocid, GSagsusedmode);
      SetAction (A_DEFAULT);
    }
    else if ((GSagsusedmode == 4) && (GetLocationType (mouse.x, mouse.y) 
== 2) && isAction (A_GIVE_TO) && (GetCharacterAt (mouse.x, mouse.y) < 0))
    {
      SetLabelColor (ACTION, 0, ActionLabelColorHighlighted);
      if (GoToCharacter (GSlocid, 0, 1, 2))
      {
        ItemGiven = character [GetPlayerCharacter ()].activeinv;
        if (IsInteractionAvailable (mrx - GetViewportX (), mry - 
GetViewportY (), MODE_USEINV) == 1)
        {
          RunCharacterInteraction (GSlocid, MODE_USEINV);
        }
        GiveInv (ItemGiven, GSlocid);
        character [GetPlayerCharacter ()].activeinv = -1;
      }
      SetAction (A_DEFAULT);
    }
    else
    {
      UpdateActionBar ();
      SetLabelColor (ACTION, 0, ActionLabelColorHighlighted);
      ProcessClick (mrx - GetViewportX (), mry - GetViewportY (), 
GSagsusedmode);
      SetAction (A_DEFAULT);
    }
  }
  //end if button left
  else if (button == RIGHT)
  {
    if (alternative_action == A_DEFAULT)
    {
      SetAction (A_DEFAULT);
      SetLabelColor (ACTION, 0, ActionLabelColorHighlighted);
      if (GetCursorMode () == 9) ProcessClick (mrx - GetViewportX (), 
mry - GetViewportY (), MODE_WALK);
      else ProcessClick (mrx - GetViewportX (), mry - GetViewportY (), 
GetCursorMode () );
       
 }
    else
    {
      SetAction (alternative_action);
      used_action = global_action;
      UpdateActionBar ();
      SetLabelColor (ACTION, 0, ActionLabelColorHighlighted);
      GSagsusedmode = GetCursorMode ();
      if ((GSagsusedmode == MODE_TALK) && (IsInteractionAvailable 
(mouse.x, mouse.y, GSagsusedmode) == 1) && (GetCharacterAt (mouse.x, 
mouse.y) < 7))
      {
        if (GoToCharacter (GSlocid, 0, 1, 2)) RunCharacterInteraction 
(GSlocid, GSagsusedmode);
      }
      else ProcessClick (mrx - GetViewportX (), mry - GetViewportY (), 
GSagsusedmode);
      SetAction (A_DEFAULT);
    }
  }
  else if (button == LEFTINV)
  {
    //left click in inventory
    if (GlobalCondition (1))
    {
      // if the mouse is in the inventory and modes Walk or pickup are selected
      SetAction (A_USE);
      if ((Extension (GSinvloc) == 'u') && 
(IsInventoryInteractionAvailable (GSlocid, MODE_USE) == 1))
      {
        // use it immediately (not with anything else)
        used_action = global_action;
        RunInventoryInteraction (GSlocid, MODE_USE);
        SetAction (A_DEFAULT);
      }
      else
      {
        SetActiveInventory (GSlocid);
      }
    }
    else  if (GlobalCondition (2) == 1)
    {
      // if the mode is useinv and the mouse is over the active inv (like "use knife on knife")
    }
    else
    {
      used_action = global_action;
      if (GetCursorMode () == 2)
      {
        if (isAction (A_USE) && IsInventoryInteractionAvailable 
(GSlocid, MODE_USE) == 1)
        {
          SetLabelColor (ACTION, 0, ActionLabelColorHighlighted);
          RunInventoryInteraction (GSlocid, MODE_USE);
          SetAction (A_DEFAULT);
        }
        else SetActiveInventory (GSlocid);
      }
      else
      {
        GSagsusedmode = GetCursorMode ();
        SetLabelColor (ACTION, 0, ActionLabelColorHighlighted);
        RunInventoryInteraction (GSlocid, GetCursorMode ());
        SetAction (A_DEFAULT);
      }
    }
  }
  else if (button == RIGHTINV)
  {
    if (alternative_action == A_DEFAULT)
    {
      SetAction (A_DEFAULT);
    }
    else
    {
      SetAction (alternative_action);
      used_action = global_action;
      GSagsusedmode = GetCursorMode ();
      if (GetCursorMode () == 2)
      {
        if (isAction (A_USE) && IsInventoryInteractionAvailable 
(GSlocid, MODE_USE) == 1)
        {
          UpdateActionBar ();
          SetLabelColor (ACTION, 0, ActionLabelColorHighlighted);
          RunInventoryInteraction (GSlocid, MODE_USE);
          SetAction (A_DEFAULT);
        }
        else SetActiveInventory (GSlocid);
      }
      else
      {
        UpdateActionBar ();
        SetLabelColor (ACTION, 0, ActionLabelColorHighlighted);
        RunInventoryInteraction (game.inv_activated, GetCursorMode ());
        SetAction (A_DEFAULT);
      }
    }
  }
}
#sectionend on_mouse_click  // DO NOT EDIT OR REMOVE THIS LINE
Some say i need panels! and Some say i dont Need them.   WHERES THE DRUGS I'm going CRAZY. Plus I must have been on Drugs and a Maniac if i was going to name the game Maniacs Mansion.

What was i thinking!!!!!

strazer

Please don't post 4 times in a row in a short period of time.
Use the "Modify" button to edit your post if you have something to add.

Also, please use the [ code ] tags when posting code. This way, special characters are preserved and it's easier to read IMO.

SMF spam blocked by CleanTalk