1
Technical forum / Re: DeleteEntity error, even though code works
« on: September 10, 2012, 06:44:58 AM »
Ah right, I see. Thank you
I noticed tho that i get another error, thats only there when I have that code in the file. If i remove it, it doesn't get the error.
I removed the deleteEntity in any case because when i reload the scene the entity seems to disappear on its own.
The error is:
07:34:54: Runtime error. Script 'scenes\Room\scr\scene_init.script', line 5
07:34:54: Call to undefined method 'SkipTo'. Ignored
I have not edited the scene_init.script, but it doesn't seem to be that file having errors, but the game.exe doing something to make the engine say there's an error there.
Here's what the whole coding looks like so far for the game.script file:
I noticed tho that i get another error, thats only there when I have that code in the file. If i remove it, it doesn't get the error.
I removed the deleteEntity in any case because when i reload the scene the entity seems to disappear on its own.
The error is:
07:34:54: Runtime error. Script 'scenes\Room\scr\scene_init.script', line 5
07:34:54: Call to undefined method 'SkipTo'. Ignored
I have not edited the scene_init.script, but it doesn't seem to be that file having errors, but the game.exe doing something to make the engine say there's an error there.
Here's what the whole coding looks like so far for the game.script file:
Code: [Select]
#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.GetControl("caption");
global MenuObject = null;
// run the "game loop" script
Game.AttachScript("scripts\game_loop.script");
//create animated sprite on scene
Game.ChangeScene(Game.StartupScene);
var wakeupanim= Scene.CreateEntity("wakeupanimation");
wakeupanim.SetSprite("Animations\wakeupscene1.sprite");
wakeupanim.X=280;
wakeupanim.Y=521;
wakeupanim.Scale=100;
//Let animated sprite animate before fade out
Sleep(5000);
//Delete sprite from scene
Scene.FadeOut(100);
Game.ChangeScene(Game.StartupScene);
//Load main actor
actor = Game.LoadActor("actors\Naomi\Naomi.actor");
Game.MainObject = actor;
actor.SubtitlesPosX = 0;
actor.SubtitlesPosY = 550;
actor.SubtitlesWidth=1324;
////////////////////////////////////////////////////////////////////////////////
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 = false;
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);
}