Problem with Inventory GUI

Started by Dr.Alban, Mon 02/06/2008 17:11:36

Previous topic - Next topic

Dr.Alban

I am a very new user, and I am basically trying to teach myself scripting as I make my first game.  So I apologize if this question is ridiculously basic.  But I have looked through the manual and the FAQs, and I can't seem to find anyone else having this problem.

Anyway, what's happening is that I can't interact with my inventory items.  There is one item that the character starts with, but in the inventory GUI, the "Look" and "Interact" commands don't do anything, even though I have defined them in my global script.  Here is the script for the look at inventory item action:


function iKeycard_Look()
{
  Display("It's the keycard you use to activate the controls of the time machine and the viewscreen.  There is a thumbprint pad for determining your identity, and a magnetic strip for transferring the information from the card to the reader.");
}


It looks as I would expect it to in the GUI, as you can see in this screenshot:



It seems like there's something missing from the item's code, however, which would allow me to actually interact with it.

Anyway, part 2 of this problem, which may or may not be related, happens when I add items to the inventory ("player.AddInventory(iAtlas)").  They show up on top of the previous items, and I still can't interact with any of them.  Are my inventory sprites too big?  Is there some line I need to add to the inventory script to make it active?  Do I need to specify the character in the Add.Inventory script (i.e. "cAlban.AddInventory(iAtlas)")? 

What's going on here?

Here are screen captures of the inventory GUI after I've added two different items to the inventory.






Dr.Alban

So, it turns out part of the problem was that I had the custom inv window selected, but I hadn't actually created a custom window.  So I turned that one off and turned on the default inv window, and now it seems I can use the inv items, but I still can't look at them.

Also, I'm unclear on where exactly the code for the item size (invMain.ItemWidth, invMain.ItemHeight) should go.

Dr.Alban

Well, for some reason, the "Look" function started working spontaneously.  Not sure what I did.

But now I'm having a much more bizarre problem with my inventory.  When I look at any of the inventory items, the inventory window becomes transparent anywhere there is an object or character on screen.  If I move the cursor at all, those parts of the screen become transparent, too, until I click on "OK" to exit the window.

Anyone know what could be causing this?


Khris

Quote from: Dr.Alban on Mon 02/06/2008 20:44:09Also, I'm unclear on where exactly the code for the item size (invMain.ItemWidth, invMain.ItemHeight) should go.
Like explained in the manual entries, the code should go into game_start, a function at the top of the global script that's called once in the very beginning of the game.

The graphical error could be caused by outdated graphics card / DirectX drivers. Try updating them to the most recent version, also try selecting another filter in winsetup.

Dr.Alban

Quote from: KhrisMUC on Tue 03/06/2008 00:52:18
Like explained in the manual entries, the code should go into game_start, a function at the top of the global script that's called once in the very beginning of the game.

Well, I had already tried putting it in there, as described in the manual, but it seems there needs to be something else with it.  Right now, I don't have anything in game_start, so there are no functions or parameters defined.  The code looks like this:


function game_start() { 
  invMain.ItemWidth = 50;
  invMain.ItemHeight = 30;

initialize_control_panel();

  KeyboardMovement.SetMode(eKeyboardMovement_Tapping);

}


I know this isn't right, but the Manual entries on Item.Width and Item.Height don't explain what action gets these parameters. 



Is it just "get"?  Something like this, maybe:
get_invMain.ItemHeight = 30;


Maybe?

I'm sorry for being so dense, but I am really just starting.  I have done so little coding prior to this, and it's just a completely new way of thinking for me.


TwinMoon

Quote from: Dr.Alban on Tue 03/06/2008 01:18:49
function game_start() { 
  invMain.ItemWidth = 50;
  invMain.ItemHeight = 30;

initialize_control_panel();

  KeyboardMovement.SetMode(eKeyboardMovement_Tapping);

}

No, this is definitely right.

I suspect your problem has to do with the sprites you use.
The lines invMain.ItemWidth = 50;  &  invMain.ItemHeight = 30; tell AGS your inventory items are never bigger than 50 pixels wide and 30 pixels high.

So what you need to do is check how wide in pixels your widest inventory sprite is and enter that number (or larger) after invMain.ItemWidth = . The same with the height.

That should take care of the overlapping.

Dr.Alban

So I can't make the dimensions smaller than my largest item?  This parameter will increase, but not decrease, the size of the sprites, right?

Khris

#8
A) Try to use equally dimensioned item graphics. Decide on a specific size, then draw every item to fit inside. Looks better, too.
B) If the size limits are bigger than the item graphic, the item will simply have a border; the graphic won't scale up or down.

You're specifing grid dimensions, every item gets drawn at the top left border of a cell, from top to bottom, left to right.

Dr.Alban

Quote from: TwinMoon on Tue 03/06/2008 01:33:49
Quote from: Dr.Alban on Tue 03/06/2008 01:18:49
function game_start() { 
  invMain.ItemWidth = 50;
  invMain.ItemHeight = 30;

initialize_control_panel();

  KeyboardMovement.SetMode(eKeyboardMovement_Tapping);

}

No, this is definitely right.

But when I script it this way, I get the following error: "GlobalScript.asc(52): Error (line 52): Undefined token 'invMain' ."

Is there something else that needs to go in here?  Do I need to define this token elsewhere?

Khris

Select your inventory GUI, then its InvWindow object. Enter "invMain" as its script name.

If you're using the default inventory window, keep in mind that this is discouraged by Chris Jones and not supported any longer. I'm not sure what the default window's script name is (if it even has one).

SMF spam blocked by CleanTalk