Linking Key Item To A Locked Door
by Peter Churness · in Game Mechanics Kit · 08/16/2009 (7:07 pm) · 6 replies
I was having an issue linking a key to a locked door and thought I may have missed something in the merge process, but discovered the issue is in the demo as well. Here's what's happening:
First, you'll see in this screenshot that the GarageDoorLocker01 object has the BlueKeyItemData set as the key to unlock.

But then if I hit the '...' button to select a key for this door I get the list of available keys:

But then when I select the blue key from the list, it sets the key object, not the datablock:

Thus it no longer works - can't find the blue key because its looking for a datablock, but the editor assigns the object not the datablock when selecting.
Am I doing something wrong?
First, you'll see in this screenshot that the GarageDoorLocker01 object has the BlueKeyItemData set as the key to unlock.

But then if I hit the '...' button to select a key for this door I get the list of available keys:

But then when I select the blue key from the list, it sets the key object, not the datablock:

Thus it no longer works - can't find the blue key because its looking for a datablock, but the editor assigns the object not the datablock when selecting.
Am I doing something wrong?
#4
>Any progress?
Yes, I've checked it. The problem is in current inventory system. It stores not the items objects, but only names of their datablocks and count. So it's wrong to refer to actual objects since they destroyed immediately after being put in the inventory.
The solution is very easy, in file serverlogickingMechanicsopenable.cs replace
The will be only string input for datablock name, not so elegant as objectLink reference to the object, but it's impossible with current inventory.
P.S. I've added this change to 1.2.3 version
08/21/2009 (8:46 am)
@Peter>Any progress?
Yes, I've checked it. The problem is in current inventory system. It stores not the items objects, but only names of their datablocks and count. So it's wrong to refer to actual objects since they destroyed immediately after being put in the inventory.
The solution is very easy, in file serverlogickingMechanicsopenable.cs replace
setTemplateField("AbstractOpenable", "keyToUnlock", "", "objectLink", "Misc", "", "Item");tosetTemplateField("AbstractOpenable", "keyToUnlock", "", "", "Misc", "", "Item");The will be only string input for datablock name, not so elegant as objectLink reference to the object, but it's impossible with current inventory.
P.S. I've added this change to 1.2.3 version
#5
But would be nice to still be able to just click the key and get the datablock name populating the field. I found in the code where it seems you could add some logic for it. Here's my work around in tools/logickingEditor/scripts/objectsList.ed.cs:
I just tested it and it works. However, I don't know if it will have any unforseen consequences in other parts of the GMK functionality. Can you tell me if this fix will work?
Thanks - and GREAT product by the way...
Peter
08/21/2009 (12:04 pm)
Thanks Yuri. That works.But would be nice to still be able to just click the key and get the datablock name populating the field. I found in the code where it seems you could add some logic for it. Here's my work around in tools/logickingEditor/scripts/objectsList.ed.cs:
function LogickingEditorObjectsList::selectButtonOnPush(%this)
{
if (%this.selectedObject.class $= "InventoryItem") {
%this.caller.selectObject(%this.selectedObject.getDatablock());
} else {
%this.caller.selectObject(%this.selectedObject);
}
// add a little pause to give engine time to close the windown correctly when double click selection appears
%this.setActive(false);
LogickingEditor.schedule(100, "toggleWindow", LogickingEditorObjectsList);
EWorldEditor.clearHighlighting();
}I just tested it and it works. However, I don't know if it will have any unforseen consequences in other parts of the GMK functionality. Can you tell me if this fix will work?
Thanks - and GREAT product by the way...
Peter
#6
it will work, however other object's templates can also use "objectLink" property for reasons of selecting actual object not datablock. Probably it will be right thing to modify "objectLink" and add "datablockLink" or something. I will think about it.
08/24/2009 (3:04 pm)
Peter,it will work, however other object's templates can also use "objectLink" property for reasons of selecting actual object not datablock. Probably it will be right thing to modify "objectLink" and add "datablockLink" or something. I will think about it.
Torque Owner Kerry Enfinger
Altered Reality Software