A way to shut off the use icon for inventory items

Started by rock_chick, Sun 06/04/2008 00:38:47

Previous topic - Next topic

rock_chick

Is there any way to de-activate the use button for an inventory item or simply not allow them to use it. For example one of my inventory items is just meant to be looked at for reference as it contains information they'll need or might not need to use in the game but that's about it.

TwinMoon

On General Settings, look for Inventory and set "Use selected inventory graphic for cursor" to false.

rock_chick

Quote from: TwinMoon on Sun 06/04/2008 02:15:54
On General Settings, look for Inventory and set "Use selected inventory graphic for cursor" to false.

I tried this but it affect every inventory item, I just want to pick and choose what ones have the same or similar effect, is that even possible. If not, whenever a inventory item can't be used for anything but reference I'll merely attach a message to the bottom of what it says when the player chooses to look at the item.

Mazoliin

How about this?

Code: ags

function repeatedly_execute() {
  if (player.ActiveInventory == iYOURINVITEM){
    player.ActiveInventory = null;
  }
}

rock_chick

Quote from: Mazoliin on Sun 06/04/2008 09:23:55
How about this?

Code: ags

function repeatedly_execute() {
  if (player.ActiveInventory == iYOURINVITEM){
    player.ActiveInventory = null;
  }
}


I tried to apply it to my room script but even after altering it a bit it still comes up with errors.

Code: ags
// room script file

function painting_Look()
  {
    character[0].FaceLocation(0, 0);
    DisplayMessage(3);
  }

function Notepad_Look()
{
  DisplayMessage(11);
}

function windows_Look()
{
  DisplayMessage(5);
  if (Game.DoOnceOnly("bedroom windows"))
  {
    ShowScore(1);
  }
}

function Notepad_PickUp()
{
DisplayMessage(12);
player.AddInventory(names_numbers);
if (Game.DoOnceOnly("take first page of notepad"))
  {
    ShowScore(4);
    (function repeatedly_execute() {
  if (player.ActiveInventory == names_numbers){
    player.ActiveInventory = null;}
}


function paper_Look()
{
DisplayMessage(0);
if (Game.DoOnceOnly("player name"))
  {
    ShowScore(2);}
}

Khris

That piece of code is supposed to go into the global script, outside any function.
If the function already exists (search for it), put lines 2 to 4 of the posted snippet at the end of the function, right above its closing }.

rock_chick

I thought I'd found the right place in the global script to place the function and how I've listed the inventory name but it's not working. The game runs but even after I've taken the item in question it says my inventory is empty. I know I am probably trying people's patience here but I am terrible with almost any type of computer code.

Code: ags
// Automatically converted interaction variables
int IntVar_Global_1 = 0;
export IntVar_Global_1;
// main global script file

#sectionstart game_start  // DO NOT EDIT OR REMOVE THIS LINE
function game_start() // called when the game starts, before the first room is loaded
  {
  }
#sectionend game_start  // DO NOT EDIT OR REMOVE THIS LINE


#sectionstart repeatedly_execute  // DO NOT EDIT OR REMOVE THIS LINE
function repeatedly_execute() {
  if (player.ActiveInventory == names_numbers){
    player.ActiveInventory = null;
  }
}
#sectionend repeatedly_execute  // DO NOT EDIT OR REMOVE THIS LINE


#sectionstart on_key_press  // DO NOT EDIT OR REMOVE THIS LINE
function on_key_press(int keycode) // called when a key is pressed. keycode holds the key's ASCII code
  {
  if (keycode==17) QuitGame(1); // Ctrl-Q
  if (keycode==363) SaveGameDialog(); // F5
  if (keycode==365) RestoreGameDialog(); // F7
  if (keycode==367) RestartGame(); // F9
  if (keycode==434) SaveScreenShot("scrnshot.pcx");  // F12
  if (keycode==9) // user presses TAB
    {
    if (menu.Visible == false) menu.Visible = true; // turn on GUI
    else menu.Visible = false; // turn off GUI
    }
  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
  }
#sectionend on_key_press  // DO NOT EDIT OR REMOVE THIS LINE
 

#sectionstart on_mouse_click  // DO NOT EDIT OR REMOVE THIS LINE
function on_mouse_click(MouseButton 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 == eMouseLeft) 
    {
    ProcessClick(mouse.x,mouse.y, mouse.Mode);
    }
  else // right-click, so cycle cursor
    {   
    mouse.SelectNextMode();
    }
  }
#sectionend on_mouse_click  // DO NOT EDIT OR REMOVE THIS LINE


#sectionstart interface_click  // DO NOT EDIT OR REMOVE THIS LINE
function interface_click(int interface, int button) 
  {
  }
#sectionend interface_click  // DO NOT EDIT OR REMOVE THIS LINE;




#sectionstart dialog_request  // DO NOT EDIT OR REMOVE THIS LINE
function dialog_request(int parameter) {
  
}
#sectionend dialog_request  // DO NOT EDIT OR REMOVE THIS LINE

#sectionstart save_Click  // DO NOT EDIT OR REMOVE THIS LINE
function save_Click(GUIControl *control, MouseButton button)
{
  SaveGameDialog();
}
#sectionend save_Click  // DO NOT EDIT OR REMOVE THIS LINE

#sectionstart look_Click  // DO NOT EDIT OR REMOVE THIS LINE
function look_Click(GUIControl *control, MouseButton button)
{
  menu.Visible = false;
  mouse.Mode = eModeLookat;
}
#sectionend look_Click  // DO NOT EDIT OR REMOVE THIS LINE

#sectionstart inven_Click  // DO NOT EDIT OR REMOVE THIS LINE
function inven_Click(GUIControl *control, MouseButton button) {
  InventoryScreen ();
}
#sectionend inven_Click  // DO NOT EDIT OR REMOVE THIS LINE

function iInventory1_Look()
{
Display("The page contains the following information. Melinda 8456 Gordan 8481 Lewis 8507 Hannah 8521");
}

function ShowScore(int score_to_add) // replacement for GiveScore()
{
  GiveScore(score_to_add);
  Display("You now have %d points[out of a possible %d",game.score, game.total_score);
}

function gMainbar_OnClick(GUI *theGui, MouseButton button)
{

}

function Button1_OnClick(GUIControl *control, MouseButton button)
{
  menu.Visible = false;
  RestoreGameDialog();
}

function exit_OnClick(GUIControl *control, MouseButton button)
{
  menu.Visible = false;
  QuitGame(1);
}

function walk_OnClick(GUIControl *control, MouseButton button)
{
  menu.Visible = false;
  mouse.Mode = eModeWalkto;
}

function touch_OnClick(GUIControl *control, MouseButton button)
{
  menu.Visible = false;
  mouse.Mode = eModeInteract;
}

function grab_OnClick(GUIControl *control, MouseButton button)
{
  menu.Visible = false;
  mouse.Mode = eModePickup;
}

function talk_OnClick(GUIControl *control, MouseButton button)
{
  menu.Visible = false;
  mouse.Mode = eModeTalkto;
}

function cWife_AnyClick()
{

}

Mazoliin

You have indeed found the right place for the code. But what's "names_numbers"?
I can't seem to find anything in you're code that tells me what it is.
In my example I've used the inventory items script name when checking the players activ inv.

rock_chick

Quote from: Mazoliin on Sun 06/04/2008 12:26:21
You have indeed found the right place for the code. But what's "names_numbers"?
I can't seem to find anything in you're code that tells me what it is.
In my example I've used the inventory items script name when checking the players activ inv.
names_numbers is the name of the inventory item.

Khris

Quote from: rock_chick on Sun 06/04/2008 12:09:58The game runs but even after I've taken the item in question it says my inventory is empty.
Well, that's a completely different problem.
Usually, before being represented by an inventory item, a portable part of your game (like a key) starts out as an object.
In the room script, inside [object's name]_PickUp (or _Interact, or whatever it is you're using), the object is turned off and the corresponding inv item is added to the inventory.
Could you post the relevant part of the room script?

Because Mazoliin's code shouldn't prevent the player from picking up anything.

rock_chick

I just checked and for some unknown reason the scripting part where I added the inventory item has disappeared from the script! What the f**K is going on?

SMF spam blocked by CleanTalk