Please login or register.

Login with username, password and session length
Advanced search  

News:

For WME related articles and tutorials visit WME Resource Center.

Author Topic: Double Click with an item  (Read 661 times)

0 Members and 1 Guest are viewing this topic.

MARTIN151

  • Lurker
  • *
  • Karma: 1
  • Offline Offline
  • Posts: 8
    • View Profile
Double Click with an item
« on: April 07, 2025, 05:29:43 PM »

Hi everyone,

I need help. I'd like to enable skiping walking by double clicking. It already works. But there is a problem. When any item is selected, the actor skips the walking, but he doesn't use the item.

Does anyone know, how to code the doubleclick use for items?

Thanks.
Logged

Mot

  • Occasional poster
  • **
  • Karma: 3
  • Offline Offline
  • Posts: 58
    • View Profile
Re: Double Click with an item
« Reply #1 on: April 09, 2025, 10:06:24 PM »

I would add an event handler to the file game.script to take care of what happens when the user left double clicks. As I don't know what you coded in order to skip (walking) to a location, you may need to modify the next example to include both behaviours.

Code: WME Script
  1. ////////////////////////////////////////////////////////////////////////////////
  2. on "LeftDoubleClick"
  3. {
  4.   // what did we double click?
  5.   var ActObj = Game.ActiveObject;
  6.   if(ActObj!=null)
  7.   {
  8.     // using an inventory item on another object
  9.     if(Game.SelectedItem != null && Game.SelectedItem!=ActObj)
  10.     {
  11.       var Item = Game.SelectedItem;
  12.       if(ActObj.CanHandleEvent(Item.Name)) ActObj.ApplyEvent(Item.Name);
  13.       else if(Item.CanHandleEvent("default-use")) Item.ApplyEvent("default-use");
  14.       else if(ActObj.CanHandleEvent("default-use")) ActObj.ApplyEvent("default-use");
  15.       else actor.Talk("I can't use these things together.");
  16.     }
  17.     // just a simple double click
  18.     else ActObj.ApplyEvent("LeftDoubleClick");
  19.   }
  20.   // else propagate the LeftDoubleClick event to a scene
  21.   else
  22.   {
  23.     Scene.ApplyEvent("LeftDoubleClick");
  24.   }
  25. }
  26. ////////////////////////////////////////////////////////////////////////////////
  27.  
« Last Edit: April 16, 2025, 12:34:50 PM by Mot »
Logged
 

Page created in 0.048 seconds with 21 queries.