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: query a selected object  (Read 3117 times)

0 Members and 1 Guest are viewing this topic.

piere

  • Supporter
  • Frequent poster
  • *
  • Karma: 4
  • Offline Offline
  • Posts: 301
  • Sorry for any bad english in my posts. Game on !
    • View Profile
query a selected object
« on: June 13, 2011, 10:37:29 AM »

Is there a way to query if a certain object is selected? Something like
if (Game.SelectedItem = "book")
{
//do something
}

Thanks
Logged

piere

  • Supporter
  • Frequent poster
  • *
  • Karma: 4
  • Offline Offline
  • Posts: 301
  • Sorry for any bad english in my posts. Game on !
    • View Profile
Re: query a selected object
« Reply #1 on: June 13, 2011, 07:46:47 PM »

I just figured it out, I used IsItemTaken to query it. Thanks anyways guys. ! ::rock
Logged

Spellbreaker

  • Supporter
  • Frequent poster
  • *
  • Karma: 4
  • Offline Offline
  • Gender: Male
  • Posts: 376
    • View Profile
    • Apeiron Studios
Re: query a selected object
« Reply #2 on: June 13, 2011, 09:39:38 PM »

Hey there.

Just as a side note: IsItemTaken does not returns if an item is selected. It returns if an item is in the inventory.
Logged

piere

  • Supporter
  • Frequent poster
  • *
  • Karma: 4
  • Offline Offline
  • Posts: 301
  • Sorry for any bad english in my posts. Game on !
    • View Profile
Re: query a selected object
« Reply #3 on: June 13, 2011, 10:17:21 PM »

Thanks Spellbreaker. You are right, is there a way I can see if the item is selected, not just in inventory? Thanks
Logged

Mnemonic

  • WME developer
  • Administrator
  • Addicted to WME forum
  • *
  • Karma: 41
  • Offline Offline
  • Gender: Male
  • Posts: 5683
    • View Profile
    • Dead:Code Site
Re: query a selected object
« Reply #4 on: June 15, 2011, 04:27:36 PM »

Game.SelectedItem returns an object, not a name. You need to query the name of the object:

Code: WME Script
  1. var selItem = Game.SelectedItem;
  2. if (selItem.Name == "something") ...
  3.  
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.018 seconds with 21 queries.