Question about Inventory items

Started by Cyberion, Wed 18/08/2004 08:42:19

Previous topic - Next topic

Cyberion

Hello,

currently i have a problem with my inventory items, i'll explain.

I'm using the controls where Player Char moves by using arrow keys and Interact with Left Mouse click and Loot at with right mouse click.

When i select item in inventory it becomes mouse cursor, but i can't switch it off. Remember in "The Dig", you select the item from inventory and you interact with the help of this item, but when you pressed right mouse button it returns you to your default interact mouse mode.  I wounder how i may do so? So far i select the item and it stays as my mouse cursor and i can't change it with right mouse click as it is in look mode. Where i need to write SetCursorMode or what ever line?

Mr Jake

in the rightclick section put

if (character[EGO].activeinv >=0){
character[EGO].activeinv = -1
}

Cyberion

I do not know I can't make it work, i made everything i could (i really suck at scripting as i do not know anything about C++ or any other language, so for me it's a real pain in the A**.


Here is my code:

function on_mouse_click(int button) {
  // called when a mouse button is clicked. button is either LEFT or RIGHT
  if (IsGamePaused() == 1) {
    // Game is paused, so do nothing (ie. don't allow mouse click)
  }
  else if (button==LEFT) {
    ProcessClick(mouse.x, mouse.y, MODE_USE);
  }
  else if (character[VOICE].activeinv >=0){    // right-click, so cycle cursor
character[VOICE].activeinv = -1;
    ProcessClick(mouse.x, mouse.y, MODE_LOOK);
   
   }
}


What's wrong? i bet there is something wrong.

Mr Jake

function on_mouse_click(int button) {
  // called when a mouse button is clicked. button is either LEFT or RIGHT
  if (IsGamePaused() == 1) {
    // Game is paused, so do nothing (ie. don't allow mouse click)
  }
  else if (button==LEFT) {
    ProcessClick(mouse.x, mouse.y, MODE_USE);
  }
  else if (button == RIGHT){
if (character[VOICE].activeinv >=0){    // right-click, so cycle cursor
    character[VOICE].activeinv = -1;
}
else ProcessClick(mouse.x, mouse.y, MODE_LOOK);
   }
}

Cyberion

no, it doesn't work :(

Here is the full code of Global Script, used your scrip, but still nothing. Also i put the second object into inventory to test if items work, so i can use for example key on the poster inside the inventory and it will desplay me "Hello world". But when i select the key, click close and than trying to use it on the hotspot (where i defined of course "use inventory on hotspot") it does nothing, no message. Can you find what's wrong as i remember that i was editing invenory section. anyway here is my global Script:

// main global script file



// ------ keyboard control ------

#define DIR_DISTANCE     10000

#define DIR_DOWN_LEFT  1
#define DIR_DOWN       2
#define DIR_DOWN_RIGHT 3
#define DIR_LEFT       4
#define DIR_STOP       5
#define DIR_RIGHT      6
#define DIR_UP_LEFT    7
#define DIR_UP         8
#define DIR_UP_RIGHT   9

int PrevDirection;

function game_start() {
  // called when the game starts, before the first room is loaded
game.text_speed = 10;
DisableCursorMode(MODE_WALK);
SetMouseCursor(6);

  // ------ keyboard control ------
  PrevDirection = DIR_STOP;
}

function repeatedly_execute()
{
  // put anything you want to happen every game cycle here

  // --- keyboard control ---
  int CharId, Direction, dx, dy;

    // get new diretion
         if ((IsKeyPressed (371) > 0) || (IsKeyPressed (55) > 0)) Direction = DIR_UP_LEFT;    // 7 Home (numeric pad)
    else if ((IsKeyPressed (372) > 0) || (IsKeyPressed (56) > 0)) Direction = DIR_UP;         // 8 Up arrow
    else if ((IsKeyPressed (373) > 0) || (IsKeyPressed (57) > 0)) Direction = DIR_UP_RIGHT;   // 9 PgUp (numeric pad)
    else if ((IsKeyPressed (375) > 0) || (IsKeyPressed (52) > 0)) Direction = DIR_LEFT;       // 4 Left arrow
    else if ((IsKeyPressed (376) > 0) || (IsKeyPressed (53) > 0)) Direction = DIR_STOP;       // 5 Stop (numeric pad)
    else if ((IsKeyPressed (377) > 0) || (IsKeyPressed (54) > 0)) Direction = DIR_RIGHT;      // 6 Right arrow
    else if ((IsKeyPressed (379) > 0) || (IsKeyPressed (49) > 0)) Direction = DIR_DOWN_LEFT;  // 1 End (numeric pad)
    else if ((IsKeyPressed (380) > 0) || (IsKeyPressed (50) > 0)) Direction = DIR_DOWN;       // 2 Down arrow
    else if ((IsKeyPressed (381) > 0) || (IsKeyPressed (51) > 0)) Direction = DIR_DOWN_RIGHT; // 3 PgDn (numeric pad)
    else Direction = DIR_STOP;

    // compare new direction with previous direction
    if (PrevDirection != Direction)
    {
      PrevDirection = Direction;
      CharId = GetPlayerCharacter ();
      if (Direction == DIR_STOP)              { StopMoving (CharId);                    }  // 5 Stop (numeric pad)
      else
      {
             if (Direction == DIR_UP_LEFT)    { dx = -DIR_DISTANCE; dy = -DIR_DISTANCE; }  // 7 Home (numeric pad)
        else if (Direction == DIR_UP)         { dx = 0;             dy = -DIR_DISTANCE; }  // 8 Up arrow
        else if (Direction == DIR_UP_RIGHT)   { dx = DIR_DISTANCE;  dy = -DIR_DISTANCE; }  // 9 PgUp (numeric pad)
        else if (Direction == DIR_LEFT)       { dx = -DIR_DISTANCE; dy = 0;             }  // 4 Left arrow
        else if (Direction == DIR_RIGHT)      { dx = DIR_DISTANCE;  dy = 0;             }  // 6 Right arrow
        else if (Direction == DIR_DOWN_LEFT)  { dx = -DIR_DISTANCE; dy = DIR_DISTANCE;  }  // 1 End (numeric pad)
        else if (Direction == DIR_DOWN)       { dx = 0;             dy = DIR_DISTANCE;  }  // 2 Down arrow
        else if (Direction == DIR_DOWN_RIGHT) { dx = DIR_DISTANCE;  dy = DIR_DISTANCE;  }  // 3 PgDn (numeric pad)
        MoveCharacterStraight (CharId, character [CharId].x + dx, character [CharId].y + dy);
      }
    }
}

function show_inventory_window () {
  // This demonstrates both types of inventory window - the first part is how to
  // show the built-in inventory window, the second part uses the custom one.
  // Un-comment one section or the other below.
 
  /*
  // ** DEFAULT INVENTORY WINDOW
  InventoryScreen();
*/ 
  // ** CUSTOM INVENTORY WINDOW
  GUIOn (INVENTORY);
  CentreGUI (2);
  // switch to the Use cursor (to select items with)
  SetCursorMode (MODE_USE);
  SetMouseCursor (6);
}

function show_quit_window () {

GUIOn (QUIT);
CentreGUI (3);
}


function on_key_press(int keycode) {
  // called when a key is pressed. keycode holds the key's ASCII code
  if (IsGamePaused() == 1) keycode=0;  // game paused, so don't react to keypresses
  if (keycode==17)  show_quit_window ();   // Ctrl-Q
  if (keycode==363) SaveGameDialog();   // F5
  if (keycode==367) RestoreGameDialog();  // F9
  if (keycode==368) show_quit_window ();  // F10
  if (keycode==359) Display("The Eclipse, Copyright (c) 2004-2005 Nikolay Ivliev"); // F1

  if (keycode==362) RestartGame();  // F4
  if (keycode==434) SaveScreenShot("scrnshot.bmp");  // F12
  if (keycode==9)   show_inventory_window();  // Tab, show inventory

  if (keycode==19)  Debug(0,0);  // Ctrl-S, give all inventory
  if (keycode==22)  Debug(1,0);  // Ctrl-V, version
  if (keycode==1)   Debug(2,0);  // Ctrl-A, show walkable areas
  if (keycode==24)  Debug(3,0);  // Ctrl-X, teleport to room
}

function on_mouse_click(int button) {
  // called when a mouse button is clicked. button is either LEFT or RIGHT
  if (IsGamePaused() == 1) {
    // Game is paused, so do nothing (ie. don't allow mouse click)
  }
  else if (button==LEFT) {
    ProcessClick(mouse.x, mouse.y, MODE_USE);
  }
  else if (button == RIGHT){
if (character[VOICE].activeinv >=0){    // right-click, so cycle cursor
    character[VOICE].activeinv = -1;
}
else ProcessClick(mouse.x, mouse.y, MODE_LOOK);
   }
}

function interface_click(int interface, int button) {
  if (interface == ICONBAR) {
    if (button == 0) {  // show inventory
      show_inventory_window();
    }
    else if (button == 1)    // save game
      SaveGameDialog();
    else if (button == 2)   // load game
      RestoreGameDialog();
    else if (button == 3)   // quit
      show_quit_window ();
    else if (button == 7)    // about
      Display("Eclipse: Burning Universe, Copyright (c) 2003-2004 Inner Vault");

}  // end if interface ICONBAR

  if (interface == INVENTORY) {
    // They clicked a button on the Inventory GUI

    if (button == 1) {
      // They pressed the OK button, close the GUI
      GUIOff (INVENTORY);
    }
 
      if ((button == 4) && (game.top_inv_item < game.num_inv_items - game.num_inv_displayed)) {
      // scroll down
      game.top_inv_item = game.top_inv_item + game.items_per_line;
    }
    if ((button == 5) && (game.top_inv_item > 0)){
      // scroll up
      game.top_inv_item = game.top_inv_item - game.items_per_line;
    }
  }
 
 
 
   if (interface == QUIT) {
    // They clicked a button on the quit GUI
   
    if (button == 0) {
    QuitGame (0);
    }
    if (button == 1) {
      // They pressed the OK button, close the GUI
      GUIOff (QUIT);
      SetMouseCursor (6);
    }
  }
}

function inventory1_a() {
  // script for inventory1: Look at inventory item
Display ("Well, this is just a key."); 
}

function inventory2_a() {
  // script for inventory2: Use inventory on this item
Display("Hello world"); 
}

Scorpiorus

Try removing the if (IsGamePaused() == 1) condition in case the game is paused by a Popup Modal GUI for example:

function on_mouse_click(int button) {
Ã,  // called when a mouse button is clicked. button is either LEFT or RIGHT
Ã,  if (button==LEFT) {
Ã,  Ã,  ProcessClick(mouse.x, mouse.y, MODE_USE);
Ã,  }
Ã,  else if (button == RIGHT){
if (character[VOICE].activeinv >=0){Ã,  Ã,  // right-click, so cycle cursor
Ã,  Ã,  character[VOICE].activeinv = -1;
}
else ProcessClick(mouse.x, mouse.y, MODE_LOOK);
Ã,  Ã, }
}

SMF spam blocked by CleanTalk