Ok, so let's analyze it a little, so that you better understand how things work under the hood:
on "RightClick"
{
// if inventory item selected? deselect it
{
return;
}
if(ActObj !=
null) ActObj.
ApplyEvent("item-deselected");
What does this script do? "If there is a selected item, deselect it and return". So in this case the script returns before ever reaching the added lines. Same case with the second version.
Now the third version looks better:
on "RightClick"
{
// if inventory item selected? deselect it
{
if(ActObj !=
null) ActObj.
ApplyEvent("item-deselected");
return;
}
"If there is a selected item, decelect it and if there is some active object under cursor, send an event to it and return".
Looks allright. You are using the SciTE editor bundled with WME to edit scripts, are you? In the Tools menu, there is an invaluable command called 'Compile', which checks your script for syntax errors (Ctrl+F7). If you use this command, you'll get:
game.script(91) : Duplicate declaration of variable 'ActObj'
It means there is a syntax error in your script, therefore the engine is not able to execute it, therefore none of the functions handled by this script will work (including the menu and a lot of other things).
From the error description it should be obvious what's wrong. The variable ActObj is declared twice, which is illegal.
// if inventory item selected? deselect it
if(ActObj !=
null) ActObj.
ApplyEvent("item-deselected");
return;
}
// is the righ-click menu visible? hide it
else if(ActObj!=null)
{
So simply move the declaration to the beginning, so that both branches of the script can use it:
// if inventory item selected? deselect it
if(ActObj !=
null) ActObj.
ApplyEvent("item-deselected");
return;
}
// is the righ-click menu visible? hide it
else if(ActObj!=null)
{
Sorry for the lengthy post, but when people post in the forum, it's usually hard to tell what their experience with scripting is. Hopefully this will help understanding some of the concepts, and if anything, the syntax-check function in SciTE was worth pointing out.