Tak si tady jen tak zkouším různě upravovat scripty z dema a chtěl bych předělat game.script tak, aby se menu akce (Talk/Take/LookAt) zobrazilo při klepnutí levého tlačítka myši na objekt. Pravé by pak fungovalo jen na odkládání zvednutých předmětů z inventáře. Bohužel to nějak nemaká. Žádnou chybu mi to sice neukazuje, ale při zobrazeném menu a klepnutím na nějaké z tlačítek se vůbec nic nestane - jen zmizí menu. Takhle jsem to změnil...možná to je blbě, nevím:
#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;
// load the right-click menu
global WinMenu = Game.LoadWindow("interface\menu\menu.window");
WinMenu.Visible = false;
// load the "caption" window
var win = Game.LoadWindow("interface\system\caption.window");
global WinCaption = win.GetWidget("caption");
global MenuObject = null;
// load our main actor
actor = Game.LoadActor3D("actors\pes\pes.act3d");
Game.MainObject = actor;
// run the "daemon" script
Game.AttachScript("scripts\game_daemon.script");
// which scene to load?
Game.ChangeScene("scenes\scene_1\scene_1.scene");
////////////////////////////////////////////////////////////////////////////////
on "LeftClick"
{
var ActObj = Game.ActiveObject;
if(ActObj!=null)
{
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 {
var id = Random(1,2);
switch(id)
{
case 1: actor.Talk("To je blbost"); break;
case 2: actor.Talk("Něco jiného"); break;
}
}
}
if(WinMenu.Visible == true) WinMenu.Visible = false;
else if(ActObj.CanHandleEvent("Take") || ActObj.CanHandleEvent("Talk") || ActObj.CanHandleEvent("LookAt"))
{
MenuObject = Game.ActiveObject;
var Caption = WinMenu.GetWidget("Caption");
Caption.Text = MenuObject.Caption;
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;
WinMenu.Visible = true;
actor.Reset();
} else ActObj.ApplyEvent("LeftClick");
} else Scene.ApplyEvent("LeftClick");
}
////////////////////////////////////////////////////////////////////////////////
on "RightClick"
{
var ActObj = Game.ActiveObject;
// if inventory item selected? deselect it
if (Game.SelectedItem != null){
Game.SelectedItem = null;
return;
}
if(ActObj!=null) ActObj.ApplyEvent("RightClick");
}
////////////////////////////////////////////////////////////////////////////////
on "Keypress"
{
// on Esc or F1 key
if(Keyboard.KeyCode==VK_ESCAPE)
{
// 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);
}
else if(Keyboard.KeyCode==VK_F1)
{
Scene.ShowGeometry = !Scene.ShowGeometry;
}
}
////////////////////////////////////////////////////////////////////////////////
on "QuitGame"
{
// on Alt+F4 (window close)
// load and display the quit confirmation window
if(QuestionBox(Game.ExpandString("/IGMENU0009/"))) Game.QuitGame();
}
////////////////////////////////////////////////////////////////////////////////
method QuestionBox(Message, SystemExclusive)
{
if(SystemExclusive==null) SystemExclusive = true;
var Window = Game.LoadWindow("interface\system\quit.window");
Window.Center();
Window.xMessage = Game.ExpandString(Message);
if(SystemExclusive) Window.GoSystemExclusive();
else Window.GoExclusive();
var Result = Window.xResult;
Game.UnloadObject(Window);
return Result;
}
Jiné soubory jsem neupravoval. Proč to tedy nejde?