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: Levé a pravé tlačítko myši- actor talk  (Read 1203 times)

0 Members and 1 Guest are viewing this topic.

sorrow

  • Occasional poster
  • **
  • Karma: 0
  • Offline Offline
  • Posts: 59
    • View Profile
Levé a pravé tlačítko myši- actor talk
« on: August 25, 2013, 08:42:43 AM »

#include "scripts\base.inc"
#include "scripts\keys.inc"

// store some of the game's attributes in global variables for convenience
Keyboard = Game.Keyboard;
Scene = Game.Scene;

actor = Game.LoadEntity("cesta_k_tvojej_entite");
actor.Active = true;

// load the right-click menu
global WinMenu = Game.LoadWindow("interface\menu\menu.window");
WinMenu.Visible =true;

// load the "caption" window
var win = Game.LoadWindow("interface\system\caption.window");
global WinCaption = win.GetControl("caption");


global MenuObject = null;


// load our main actor
actor = Game.LoadEntity("actors\sten\sten.entity");
actor.Active = true;

// run the "game loop" script
Game.AttachScript("scripts\game_loop.script");


// which scene to load?
Game.ChangeScene(Game.StartupScene);

// load the dialogbox window
WinDialogBox = Game.LoadWindow("interface\dialogbox\dialogbox.window");
WinDialogBox.Visible = false;


////////////////////////////////////////////////////////////////////////////////
on "LeftClick"
{
  // what did we click?
  var ActObj = Game.ActiveObject;
  if(ActObj!=null)
  {
    // clicking an inventory item
    if(ActObj.Type=="item" && Game.SelectedItem==null)
    {
      Game.SelectedItem = ActObj;
    }
    // using an inventory item on another object
    else if(Game.SelectedItem != null && Game.SelectedItem!=ActObj)
    {
      var Item = Game.SelectedItem;
      if(ActObj.CanHandleEvent(Item.Name)) ActObj.ApplyEvent(Item.Name);
      else if(Item.CanHandleEvent("default-use")) Item.ApplyEvent("default-use");
      else if(ActObj.CanHandleEvent("default-use")) ActObj.ApplyEvent("default-use");
      else actor.Talk("I can't use these things together.");
    }
    // just a simple click
    else ActObj.ApplyEvent("LeftClick");
  }
  // else propagate the LeftClick event to a scene
  else
  {
    Scene.ApplyEvent("LeftClick");
  }
}



////////////////////////////////////////////////////////////////////////////////
on "RightClick"
{
  // if inventory item selected? deselect it
  if (Game.SelectedItem != null){
    Game.SelectedItem = null;
    return;
  }

  var ActObj = Game.ActiveObject;

  // is the righ-click menu visible? hide it
  if(WinMenu.Visible == true) WinMenu.Visible = true;
  else if(ActObj!=null)
  {
    // if the clicked object can handle any of the "verbs", display the right-click menu
    if(ActObj.CanHandleEvent("Take") || ActObj.CanHandleEvent("Talk") || ActObj.CanHandleEvent("LookAt"))
    {
      // store the clicked object in a global variable MenuObject
      MenuObject = Game.ActiveObject;
      var Caption = WinMenu.GetControl("caption");
      Caption.Text = MenuObject.Caption;

      // adjust menu's position
      WinMenu.X = Game.MouseX - WinMenu.Width / 2;
      if(WinMenu.X < 0) WinMenu.X = 0;
      if(WinMenu.X+WinMenu.Width>Game.ScreenWidth) WinMenu.X = Game.ScreenWidth-WinMenu.Width;

      WinMenu.Y = Game.MouseY - WinMenu.Height / 2;
      if(WinMenu.Y<0) WinMenu.Y = 0;
      if(WinMenu.Y+WinMenu.Height>Game.ScreenHeight) WinMenu.Y = Game.ScreenHeight-WinMenu.Height;

      // and show the right-click menu
      WinMenu.Visible = true;

      // stop the actor from whatever he was going to do
      actor.Reset();
    }
    // no verbs supported, no menu is needed; just send the RightClick event to the object
    else ActObj.ApplyEvent("RightClick");
  }
}


////////////////////////////////////////////////////////////////////////////////
on "Keypress"
{
  // on Esc or F1 key
  if(Keyboard.KeyCode==VK_ESCAPE || Keyboard.KeyCode==VK_F1)
  {
    // load and display the main menu window
    WinCaption.Visible = false;
    var WinMainMenu = Game.LoadWindow("interface\system\mainmenu.window");
    WinMainMenu.Center();
    WinMainMenu.GoSystemExclusive();
    Game.UnloadObject(WinMainMenu);
  }
}


////////////////////////////////////////////////////////////////////////////////
on "QuitGame"
{
  // on Alt+F4 (window close)
  // load and display the quit confirmation window
  WinCaption.Visible = false;
  var WinQuit = Game.LoadWindow("interface\system\quit.window");
  WinQuit.Center();
  WinQuit.GoSystemExclusive();

  // and if the user selected Yes
  if(WinQuit.xResult)
  {
    // quit the game
    Game.QuitGame();
  }
  // otherwise just unload the quit window from memory
  else Game.UnloadObject(WinQuit);
}

- a Nyní potřebuji od někoho zkušeného aby mi poradil - jak udělat aby když kliknu levým tlačítkem nebo pravým- nevyskakovalo okno s nabídkou lupy - bubliny a tak-- a aby prostě jednoduše fungovalo ve scéně když kliknu levým tlačítkem myši actor mluví ...
kliknu pravým actor také mluví ( viz actor talk..) -- děkuji za ochotu sna
« Last Edit: August 25, 2013, 08:44:16 AM by sorrow »
Logged

NAItReIN

  • Occasional poster
  • **
  • Karma: 1
  • Offline Offline
  • Posts: 57
    • View Profile
Re: Levé a pravé tlačítko myši- actor talk
« Reply #1 on: August 25, 2013, 11:26:17 PM »

Quote
aby prostě jednoduše fungovalo ve scéně když kliknu levým tlačítkem myši actor mluví ...
kliknu pravým actor také mluví ( viz actor talk..) -- děkuji za ochotu sna

Stačí si vytvoriť skript ku konkrétnemu objektu a použiť udalosti on LeftClick a on RightClick.
Logged
 

Page created in 0.159 seconds with 17 queries.