Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: barefoot on Thu 25/02/2010 11:20:28

Title: btnIconInv.Enabled = false; plus text display
Post by: barefoot on Thu 25/02/2010 11:20:28
Hi

I am using:


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
Title: Re: btnIconInv.Enabled = false; plus text display
Post by: Khris on Thu 25/02/2010 13:06:54
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:

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
Title: Re: btnIconInv.Enabled = false; plus text display
Post by: barefoot on Thu 25/02/2010 14:07:03
thanks khris

barefoot
Title: Re: btnIconInv.Enabled = false; plus text display
Post by: Arjunaz78 on Sun 16/10/2011 06:29:25
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..

btnIconInv_OnClick(...)

instead of

function btnIconInv_Click(GUIControl *control, MouseButton button)

on Global.asc..
why and how can i edit and change it???
Title: Re: btnIconInv.Enabled = false; plus text display
Post by: Calin Leafshade on Sun 16/10/2011 06:40:34
Its the same thing. Khris was just being *totally and shamefully lazy* when he typed it out.
Title: Re: btnIconInv.Enabled = false; plus text display
Post by: Khris on Sun 16/10/2011 14:27:09
To quote myself:
// 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.
Title: Re: btnIconInv.Enabled = false; plus text display
Post by: Arjunaz78 on Wed 19/10/2011 17:23:37
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..  :-[
Title: Re: btnIconInv.Enabled = false; plus text display
Post by: pcj on Wed 19/10/2011 23:11:04
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.
Title: Re: btnIconInv.Enabled = false; plus text display
Post by: Arjunaz78 on Thu 20/10/2011 16:22:12
So that's mean i have to set or using the 'if' & 'else' statement between the function,right?
Title: Re: btnIconInv.Enabled = false; plus text display
Post by: pcj on Thu 20/10/2011 16:23:14
Yes, that's right.
Title: Re: btnIconInv.Enabled = false; plus text display
Post by: Arjunaz78 on Sat 22/10/2011 11:55:36
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..


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..


player.Room...


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

THX.
Title: Re: btnIconInv.Enabled = false; plus text display
Post by: Khris on Sat 22/10/2011 12:33:57
HasPlayerBeenInRoom() remains true even when the player leaves room 5 (since he has been to the room).

Do you need this:

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.