Please login or register.

Login with username, password and session length
Advanced search  

News:

Latest WME version: WME 1.9.1 (January 1st, 2010) - download

Author Topic: Inventory Item not Visible  (Read 5083 times)

0 Members and 1 Guest are viewing this topic.

sharkbait

  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 13
    • View Profile
Inventory Item not Visible
« on: February 12, 2007, 01:53:46 AM »

Hi,

I'm experiencing a very strange problem with the inventory. I am planning to use multiple inventories attached to multiple characters. When I get a character to pick an item and place it in the (empty) inventory, it is automatically removed from the scene, however the item is not visible in the inventory. The weird thing is that the right scrolling button within the inventory becomes enabled and if I click it, the left scrolling button is enabled while the right is disabled again. So it is as if the inventory contains the item but for some reason it is not displayed, and nor am I able to pick up the item from it.

Here is what I've done:

Code in game.script:
Code: [Select]
// load our main actor
g_actor = Game.LoadActor("actors\Player\Player.actor");
Game.MainObject = g_actor;

// attach inventory to actor
Game.InventoryObject = g_actor;

The scene item is a sprite region called 'book' with an associated scene/scr script:
Code: [Select]
#include "scripts\base.inc"

on "LookAt"
{
  g_actor.GoToObject(this);
  g_actor.Talk("Hmmm.. it's the WME manual.");
}

on "Take"
{
Game.Interactive = false;
g_actor.GoToObject(this);
g_actor.Talk("I'll take it.");
g_actor.TakeItem("book");
Game.Interactive = true;
}

on "Talk"
{
  g_actor.Talk("Shouldn't I read it instead?");
}

on "LeftClick"
{
  g_actor.GoToObject(this);
}

The 'book' item itself is defined by some images, a script and an entry in item.items:

book item script:
Code: [Select]
#include "scripts\base.inc"

on "LookAt"
{
  g_actor.Talk("Guess I should read through this...");
}

on "Take"
{
}

item.items entry:
Code: [Select]
ITEM
{
   CURSOR_COMBINED = TRUE
   CAPTION = "WME User's Guide"
   NAME = "book"
   IMAGE = "items\book.png"
   CURSOR = "items\book.png"
   CURSOR_HOVER = "items\book_h.png"
   SCRIPT = "items\book.script"
}

I'm really stumped on this problem, as no error is being issued, so I have no idea why the inventory is refusing to display the item.
Hope you can help,
Regards,
Sharkbait
« Last Edit: February 12, 2007, 12:17:18 PM by sharkbait »
Logged

Mnemonic

  • WME developer
  • Administrator
  • Addicted to WME forum
  • *
  • Karma: 41
  • Offline Offline
  • Gender: Male
  • Posts: 5683
    • View Profile
    • Dead:Code Site
Re: Inventory Item not Visible
« Reply #1 on: February 12, 2007, 08:33:38 PM »

The code looks ok, and I wasn't able to replicate any problem with WME demo. So, perhaps the problem is in the book.png image? What if you try replacing it with the image from WME demo?
Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum. ::wave

sharkbait

  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 13
    • View Profile
Re: Inventory Item not Visible
« Reply #2 on: February 12, 2007, 09:40:02 PM »

I tried reverting to the old bmp images but I still experience the same problem.

I also added a second object and the inventory appears consistent. For example, after I pick the two objects I can click the left and right buttons on the inventory twice in a row, consistent with the fact that the inventory contains two (invisible!) items. I'm also unable to do any action on the items once in the inventory, presumably because there is no mouse cursor - item overlap.

Is there anything I can check at my end? I tried inspecting the global actor variable (g_actor) for an 'Items' property or something similar but I didn't find anything.

Also, I don't know if this is relevant, but I reorganised the directory structure. As far as I am aware, all the references point to the right paths and everything else appears to be working. Could this be the source of the problem?
Logged

Mnemonic

  • WME developer
  • Administrator
  • Addicted to WME forum
  • *
  • Karma: 41
  • Offline Offline
  • Gender: Male
  • Posts: 5683
    • View Profile
    • Dead:Code Site
Re: Inventory Item not Visible
« Reply #3 on: February 12, 2007, 10:31:30 PM »

Obviously everything else works but the display. Try tweaking the inventory definition file, changing the cell size and/or the area for items. If everything else fails, you can make some minimal demo for us to take a look at.
Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum. ::wave

sharkbait

  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 13
    • View Profile
Re: Inventory Item not Visible
« Reply #4 on: February 12, 2007, 10:47:10 PM »

Ok I will try.

I don't know if this is of any relevance but I noticed that the Item definition in items.items uses an IMAGE property while the examples in the help file use SPRITE and SPRITE_HOVER. Are these equivalent? I tried using both of course.

Thanks
Logged

Mnemonic

  • WME developer
  • Administrator
  • Addicted to WME forum
  • *
  • Karma: 41
  • Offline Offline
  • Gender: Male
  • Posts: 5683
    • View Profile
    • Dead:Code Site
Re: Inventory Item not Visible
« Reply #5 on: February 12, 2007, 10:49:42 PM »

Yes, they're equivalent.
Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum. ::wave

sharkbait

  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 13
    • View Profile
Re: Inventory Item not Visible
« Reply #6 on: February 12, 2007, 11:21:07 PM »

I found the problem! :)

The AREA section needed to be one pixel wider and taller. I was assuming that for an area of size W x H set at X, Y, the co-ordinates are (X,Y) - (X + W -1, Y + H - 1). The correct coords are (X,Y) - (X + W, Y + H).

Thanks for pointing me in the right direction!
Logged

goldenTouch

  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 26
    • View Profile
    • Spare Time Gaming
Re: Inventory Item not Visible
« Reply #7 on: February 14, 2007, 08:39:48 PM »

I'm having the same problem - only I'm not sure how this works.
For now, I'm using the default inventory image that comes with WME.

One of the inventory items is the default "book".
Another one is something I call "Axe". This image is 65x75.

What do I need to do with the inventory definition file?
What values should I use?

It appears that my inventory items are not displayed for the same reasons as the last person, but I may be wrong.
Logged

sharkbait

  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 13
    • View Profile
Re: Inventory Item not Visible
« Reply #8 on: February 14, 2007, 10:05:31 PM »

For starters, as Mnemonic said, make sure that the item cell dimensions are less than those of the area dimensions.

For example, in inventory.def you have a section:
Code: [Select]
INVENTORY_BOX
{
  ITEM_WIDTH = 65
  ITEM_HEIGHT = 65
  SPACING = 10
  SCROLL_BY = 1
  HIDE_SELECTED = TRUE

  AREA { 30, 12, 770, 77 }
  EXCLUSIVE = FALSE
:
:
}

In thr above example, the CELL (item) width and height are both 65 pixels.

The AREA is the part of the inventory window that contains the items and in the above example it's width is 740 (770 - 30) and 65 (77 - 12). The WME engine will fit as many items in this area that fit, and spaced 10 pixels apart (because SPACING = 10). In fact, 10 items will fit (65 x 10 = 650) plus the 9 spaces in between (10 x 9 = 90) making an exact total of 740.

If you increase the are height to fit another 65 + 10 pixels (by changing 77 to 77 + 75 = 152), you can get an inventory of 10 items across by 2 items down.

You always need to be careful with the calculations as even specifying one pixel less can cause you to loose a whole column or whole row of items. In my case I ended up with an inventory of 10 x 0 items hence no items visible at all!

Hope that helps!

P.S. If you start dabbling with the ui_element images to change the window interface, you will notice a similar behaviour when the window size is not an exact multiple of the window image sizes.
Logged

goldenTouch

  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 26
    • View Profile
    • Spare Time Gaming
Re: Inventory Item not Visible
« Reply #9 on: February 14, 2007, 10:32:18 PM »

Thank you. I got it now.  :)
Logged
 

Page created in 0.035 seconds with 20 queries.