Test Facility?

DavyB
11 Apr 2020, 16:22During testing it would be useful to have a command that adds a non-scenery item to the player's inventory no matter where it resides and even if it has been 'removed'. Does anyone have a neat way to do this? It would be even better if there was a prompt when several items with the same name exist!
>find brass key
mrangel
11 Apr 2020, 20:21Off the top of my head:
<command name="obtain">
<pattern>obtain #object#</pattern>
<scope>world</scope>
<script>
object.parent = game.pov
</script>
</command>
It would be even better if there was a prompt when several items with the same name exist!
Well, you get the disambiguation prompt. All I'm doing is using the scope world
, which means that it adds AllObjects()
to scope.
If you mean distinguishing between different objects with the same alias, a little javascript may help:
JS.eval ("$(function () {var i = addText;addText = t => i(t.replace(/'ShowMenuResponse','(.+?)'\\)\"/, (a,b) => a + ' title=\"'+b+'\"'));});")
(added to the ui init script while you're testing, this lets you hover the mouse over an object alias in the disambiguation menu and see the object's name in the tooltip)

DavyB
12 Apr 2020, 06:51Wow mrangel! ...many thanks for the fast and extremely helpful response. I expected you to have an answer but nothing this neat!! The command script is just what I was looking for. I also tried out the JavaScript but Quest is reporting a parsing error. I don't think I need it anyway, as the disambiguation prompt with the command feels sufficient. I did add a line just to make clear what I'd picked up:
msg ("You now have " + GetDisplayName (object) + ".")
Again, many thanks!
mrangel
12 Apr 2020, 09:35I also tried out the JavaScript but Quest is reporting a parsing error.
My mistake. I tested it by running the javascript in the the console on someone else's game. Missed out a \
when I wrapped it in Quest code. Is fixed now :)
And while I was looking at that I thought of an alternative use case:
If you find yourself wanting this functionality at short notice while testing a game, you can go to the JS console (Ctrl+Shift+J I think) and enter:
$('#divOutput a.cmdlink[onclick*=ShowMenuResponse]').each(function (){$(this).append($(this).attr('onclick').replace(/^.+'(.+?)'\)$/,' [object name:$1]'));});
That will append the object name to any currently-displayed menus :)