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: Object.variable?  (Read 2150 times)

0 Members and 1 Guest are viewing this topic.

NolaADD

  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 13
    • View Profile
Object.variable?
« on: September 24, 2008, 09:38:46 PM »

I'm trying to write a script for the game I'm developing that allows specific mouseover captions for objects, based on the inventory item that is selected. So for example, if you selected a hammer and moused over any object, the default caption would be "use hammer with [object]", but if you moused over a toolbox, it would say "put hammer back in toolbox".

I have the special captions stored inside the objects' script. For this example, toolbox.script contains this attribute: toolbox.hammer = "put hammer back in toolbox"; so that when you mouseover with the hammer, the game.loop script looks for ActiveObject.SelectedItemName and if it exists, displays that caption instead of the default one. The problem is, I can't seem to find a way for game.loop to test whether or not ActiveObject.SelectedItemName exists. I've been told that eval() is a possibility, because it can turn a string into a command, but Wintermute doesn't support it. What would the code look like that would allow me to test this dynamically?
Logged

Mnemonic

  • WME developer
  • Administrator
  • Addicted to WME forum
  • *
  • Karma: 41
  • Offline Offline
  • Gender: Male
  • Posts: 5683
    • View Profile
    • Dead:Code Site
Re: Object.variable?
« Reply #1 on: September 24, 2008, 09:46:54 PM »

Use something like this:

Code: WME Script
  1.   var PropName = "Filename"; // or whatever property you want to query
  2.   if(SomeObject[PropName] != null) ...
  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.044 seconds with 25 queries.