Please login or register.

Login with username, password and session length
Advanced search  

News:

This forum provides RSS feed. To query recent posts use this url. More...


Author Topic: Disable, but not hide item in inventory  (Read 3116 times)

0 Members and 1 Guest are viewing this topic.

Art

  • Occasional poster
  • **
  • Karma: 0
  • Offline Offline
  • Posts: 54
    • View Profile
Disable, but not hide item in inventory
« on: April 06, 2006, 12:12:41 PM »

Is there any way to disable item in inventory from selecting?

I tried folowing code, but it does not work:
Code: [Select]
var i = Game.GetItem( "astral_zre" );
i.Interactive = false;
i.Active = false;

Just nothing happens...
Logged

Mnemonic

  • WME developer
  • Administrator
  • Addicted to WME forum
  • *
  • Karma: 41
  • Offline Offline
  • Gender: Male
  • Posts: 5683
    • View Profile
    • Dead:Code Site
Re: Disable, but not hide item in inventory
« Reply #1 on: April 06, 2006, 12:21:20 PM »

You'll need to handle it in game.script. There's a piece of code in the LeftClick handler like this:

Code: [Select]
// clicking an inventory item
if(ActObj.Type=="item" && Game.SelectedItem==null)
{
  Game.SelectedItem = ActObj;
}

So add some additional condition to check if the item can be selected or not. For example, set some custom property to your item, like:

Code: [Select]
var SomeItem = Game.GetItem("some_item");
SomeItem.IsDisabled = true;

and change game.script to:

Code: [Select]
if(ActObj.Type=="item" && ActObj.IsDisabled != true && Game.SelectedItem==null)
{
  Game.SelectedItem = ActObj;
}

The .Interactive and .Active properties only affect scene objects, they don't have any effect on inventory items.

(untested, but you get the idea)
Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum. ::wave

Art

  • Occasional poster
  • **
  • Karma: 0
  • Offline Offline
  • Posts: 54
    • View Profile
Re: Disable, but not hide item in inventory
« Reply #2 on: April 06, 2006, 12:54:10 PM »

This code does not work - it comes out with script error :(
Code: [Select]
i.SavedHoverSprite = i.GetHoverSprite();

In help of Item class there is:
Quote
GetHoverSprite()
Queries a hover sprite of this item.

Return value
Returns filename of the currently assigned sprite.

Logged

Art

  • Occasional poster
  • **
  • Karma: 0
  • Offline Offline
  • Posts: 54
    • View Profile
Re: Disable, but not hide item in inventory
« Reply #3 on: April 06, 2006, 12:57:28 PM »

Even more
GetSprite - return hover one :)
Logged

Mnemonic

  • WME developer
  • Administrator
  • Addicted to WME forum
  • *
  • Karma: 41
  • Offline Offline
  • Gender: Male
  • Posts: 5683
    • View Profile
    • Dead:Code Site
Re: Disable, but not hide item in inventory
« Reply #4 on: April 06, 2006, 12:58:47 PM »

Yes, unfortunately there was a bug in WME 1.5. It's already fixed in the latest build of WME 1.6beta2
Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum. ::wave
 

Page created in 0.036 seconds with 20 queries.