46
Technical forum / Can't use object
« on: December 04, 2008, 06:06:48 AM »
I have an unusual situation. I have a door key that the actor (first person actor) gets via code in a script on a window button in a dialogue in that window script.
When I gave the actor this key before in script in the scene everything worked fine, the actor could use it on the door. Now getting it via code on a button creates mischief!!
Now the door says I can't use this key on the door. I'm just really puzzled. Nothing changed except how the actor gets the key. ? I don't get a script error in WME log, I just can't use the nice key that appears in inventory. I get a message in the game that says it can't be used on this object--the door.
This is the script on the door where the key is supposed to be used:
#include "scripts\base.inc"
global DoorUnlocked;
on "LeftClick"
{
Game.Interactive = false;
if (!DoorUnlocked)
{
Game.Msg("The door is locked and you don't have the right key.");
Game.Interactive = true;
}
}
on "key"
{
Game.Interactive = false;
DoorUnlocked = true;
Game.Msg("You unlock the door with your key.");
Game.DeleteItem("key");
Game.ChangeScene("scenes\Tunnels\Tunnels.scene");
Game.Interactive = true;
}
This is the script on the window in the scene where the actor gets the key--the stuff on Goodbye is just to close out the window--I had trouble with that. All my dialogues and images stayed on the screen. I'm using a special window to show dialogue. I like it and would like to keep it. The Buttop stuff is just the buttons that are pressed.
#include "scripts\base.inc"
on "Buttop1"
{
var a = this.GetControl("Buttop2");
a.Text = "Ready for action. Here take this key.";
var key = Scene.GetNode("key");
actor.TakeItem("key");
}
on "Buttop3"
{
var b = this.GetControl("Buttop4");
b.Text = "Princess Vasilisa's Book of Weather Spells is missing. That could mean mischief in the wrong hands. Let me hop in your back pack and let's go.";
actor.TakeItem("kolo");
}
on "Goodbye"
{
var d = this.GetControl("Buttop1");
d.ParentNotify = false;
d.Text = "";
var e = this.GetControl("Buttop2");
e.ParentNotify = false;
e.Text = "";
var f = this.GetControl("Buttop3");
f.ParentNotify = false;
f.Text = "";
var g = this.GetControl("Buttop4");
g.ParentNotify = false;
g.Text = "";
var h = this.GetControl("Face");
h.SetImage(null);
h.ParentNotify = false;
var i = this.GetControl("Goodbye");
i.Text = "";
i.ParentNotify = false;
var j = this.GetControl("Textbox");
j.SetImage(null);
j.ParentNotify = false;
}
This is my Items/items script:
ITEM
{
CURSOR_COMBINED = TRUE
CAPTION = "Agent Kolobok"
NAME = "kolo"
SPRITE = "items\kolo.png"
CURSOR = "items\kolo.png"
CURSOR_HOVER = "items\kolo.png"
SCRIPT = "items\kolo.script"
}
ITEM
{
CURSOR_COMBINED = TRUE
CAPTION = "Key"
NAME = "key"
SPRITE = "items\key.png"
CURSOR = "items\key.png"
CURSOR_HOVER = "items\key.png"
SCRIPT = "items\key.script"
}
Sigh--it's a nice scene--but I can't get it to work now since I added the dialogue window. : { And I really like the dialogue window.
When I gave the actor this key before in script in the scene everything worked fine, the actor could use it on the door. Now getting it via code on a button creates mischief!!
Now the door says I can't use this key on the door. I'm just really puzzled. Nothing changed except how the actor gets the key. ? I don't get a script error in WME log, I just can't use the nice key that appears in inventory. I get a message in the game that says it can't be used on this object--the door.
This is the script on the door where the key is supposed to be used:
#include "scripts\base.inc"
global DoorUnlocked;
on "LeftClick"
{
Game.Interactive = false;
if (!DoorUnlocked)
{
Game.Msg("The door is locked and you don't have the right key.");
Game.Interactive = true;
}
}
on "key"
{
Game.Interactive = false;
DoorUnlocked = true;
Game.Msg("You unlock the door with your key.");
Game.DeleteItem("key");
Game.ChangeScene("scenes\Tunnels\Tunnels.scene");
Game.Interactive = true;
}
This is the script on the window in the scene where the actor gets the key--the stuff on Goodbye is just to close out the window--I had trouble with that. All my dialogues and images stayed on the screen. I'm using a special window to show dialogue. I like it and would like to keep it. The Buttop stuff is just the buttons that are pressed.
#include "scripts\base.inc"
on "Buttop1"
{
var a = this.GetControl("Buttop2");
a.Text = "Ready for action. Here take this key.";
var key = Scene.GetNode("key");
actor.TakeItem("key");
}
on "Buttop3"
{
var b = this.GetControl("Buttop4");
b.Text = "Princess Vasilisa's Book of Weather Spells is missing. That could mean mischief in the wrong hands. Let me hop in your back pack and let's go.";
actor.TakeItem("kolo");
}
on "Goodbye"
{
var d = this.GetControl("Buttop1");
d.ParentNotify = false;
d.Text = "";
var e = this.GetControl("Buttop2");
e.ParentNotify = false;
e.Text = "";
var f = this.GetControl("Buttop3");
f.ParentNotify = false;
f.Text = "";
var g = this.GetControl("Buttop4");
g.ParentNotify = false;
g.Text = "";
var h = this.GetControl("Face");
h.SetImage(null);
h.ParentNotify = false;
var i = this.GetControl("Goodbye");
i.Text = "";
i.ParentNotify = false;
var j = this.GetControl("Textbox");
j.SetImage(null);
j.ParentNotify = false;
}
This is my Items/items script:
ITEM
{
CURSOR_COMBINED = TRUE
CAPTION = "Agent Kolobok"
NAME = "kolo"
SPRITE = "items\kolo.png"
CURSOR = "items\kolo.png"
CURSOR_HOVER = "items\kolo.png"
SCRIPT = "items\kolo.script"
}
ITEM
{
CURSOR_COMBINED = TRUE
CAPTION = "Key"
NAME = "key"
SPRITE = "items\key.png"
CURSOR = "items\key.png"
CURSOR_HOVER = "items\key.png"
SCRIPT = "items\key.script"
}
Sigh--it's a nice scene--but I can't get it to work now since I added the dialogue window. : { And I really like the dialogue window.