btnIconInv.Enabled = false; plus text display

Started by barefoot, Thu 25/02/2010 11:20:28

Previous topic - Next topic

barefoot

Hi

I am using:

Code: ags

btnIconInv.Enabled = false;


It works perfect. My only question is is it possible to have some kind of text displayed explaining why you can't access inventory...

Something like "It's best not to let anyone here know what you have, keep it hidden"

thanks for any help on this

UPDATE
Meanwhile Im using 'Say' on entry to Room, which may well suffice...  and then Enabling btnIconInv at a certain point in that Room.

Just wonder if my query was possible.

bareoot
I May Not Be Perfect but I Have A Big Heart ..

Khris

Sure. Leave the button enabled, and in the button's OnClick function, intercept what it usually does and display the message instead.

In Global.asc, look for btnIconInv_OnClick(...).

Change its top to:

Code: ags
function btnIconInv_OnClick(...)   // leave in the parameters as they are, of course
{
  if (condition_preventing_inv_access) {
    Display("It's best not to let anyone here know what you have, keep it hidden.");
    return;  // exit function
  }

  // rest of function, i.e. standard behavior

barefoot

I May Not Be Perfect but I Have A Big Heart ..

Arjunaz78

I try to create a custom text like this too but i don't know how & where to edit it..i use AGS Editor v3.2.1 and i can't find the..

Code: ags
btnIconInv_OnClick(...)


instead of

Code: ags
function btnIconInv_Click(GUIControl *control, MouseButton button)


on Global.asc..
why and how can i edit and change it???
..In the making of Silent Hill: The Hospital..

https://www.facebook.com/ArjunazGamesStudio

Calin Leafshade

Its the same thing. Khris was just being *totally and shamefully lazy* when he typed it out.

Khris

To quote myself:
Code: ags
// leave in the parameters as they are, of course


I can't believe I've added that back then but seeing it still fail is pretty funny and a little sad.

Arjunaz78

I still can't get through this..because i've to edit it on GlobalScript.asc that will effect the whole of my games right?

What i need is only for certain room only and not whole room/whole games..how to coding that scripting?anybody can show me the more detail sample?

besides,i don't have knowledge about scripting language before..  :-[
..In the making of Silent Hill: The Hospital..

https://www.facebook.com/ArjunazGamesStudio

pcj

It has to be in the globalscript because GUIs are globally accessible.  If you only want to show it in one room, you'll have to check if player.Room (the current room) is the room you wish to have it displayed in.
Space Quest: Vohaul Strikes Back is now available to download!

Arjunaz78

So that's mean i have to set or using the 'if' & 'else' statement between the function,right?
..In the making of Silent Hill: The Hospital..

https://www.facebook.com/ArjunazGamesStudio

pcj

Space Quest: Vohaul Strikes Back is now available to download!

Arjunaz78

Uh...still doesn't work correctly,or i just miss something important or maybe i've put a wrong code..i just create the code as below..

Code: ags

function btnIconInv_Click(GUIControl *control, MouseButton button) {
  
  if (HasPlayerBeenInRoom(5))
    Display("You Carrying Nothing");  
   
  else  {
     show_inventory_window();
}
}


but it seems the code doesn't work correctly,besides it's already display the "You Carrying Nothing" text although after the character change room.what's wrong?
besides, i don't know to continue the code after i place..

Code: ags

player.Room...


Currently i'm weak on scripting and don't know to continue with the rest of above code..

THX.
..In the making of Silent Hill: The Hospital..

https://www.facebook.com/ArjunazGamesStudio

Khris

HasPlayerBeenInRoom() remains true even when the player leaves room 5 (since he has been to the room).

Do you need this:

Code: ags
function btnIconInv_Click(GUIControl *control, MouseButton button) {
  
  if (player.Room == 5) Display("You Carrying Nothing");  
  else show_inventory_window();
}


This checks the players current room.

SMF spam blocked by CleanTalk