Quest JS - TAKE Issue

This is the error I get when trying to take something in a game compiled with Quest JS:

TypeError: parameters is undefined[Learn More]
game.js:3366:47
multipleobjects
file:///C:/Users/kv/Documents/qjs/Take%20Test/game.js:3366:47
runscriptattribute2
file:///C:/Users/kv/Documents/qjs/Take%20Test/game.js:1964:5
ResolveNextName
file:///C:/Users/kv/Documents/qjs/Take%20Test/game.js:9149:1
HandleSingleCommandPattern
file:///C:/Users/kv/Documents/qjs/Take%20Test/game.js:9117:1
HandleSingleCommand
file:///C:/Users/kv/Documents/qjs/Take%20Test/game.js:9098:1
HandleCommand
file:///C:/Users/kv/Documents/qjs/Take%20Test/game.js:9016:1
sendCommandInternal
file:///C:/Users/kv/Documents/qjs/Take%20Test/game.js:540:5
sendCommand/<

This is the take object:

_obj283 = {
"elementtype": "object",
"name": "take",
"type": "command",
"pattern": "^take (?<object>.*)$|^get (?<g2_map_object>.*)$|^pick up (?<g3_map_object>.*)$",
"multiple": function() { var takeList = NewObjectList();
var list_obj = ListExclude(ScopeVisibleNotHeldNotScenery(), _obj281.pov);
var list_obj_isarray = (Object.prototype.toString.call(list_obj) === '[object Array]');
for (var iterator_obj in list_obj) {
var obj = list_obj_isarray ? list_obj[iterator_obj] : iterator_obj;
if (list_obj_isarray || iterator_obj!="__dummyKey") { if (obj.parent == _obj281.pov.parent) {
listadd (takeList, obj);
} }
}
return (takeList); },
"scope": "notheld",
"multipleobjects": function(parameters) { var object = parameters['object'];
var multiple = parameters['multiple'];
set(_obj281.pov, "currentcommandpendingobjectscope", NewObjectList());
var list_obj = ListExclude(ScopeVisibleNotHeldNotScenery(), _obj281.pov);
var list_obj_isarray = (Object.prototype.toString.call(list_obj) === '[object Array]');
for (var iterator_obj in list_obj) {
var obj = list_obj_isarray ? list_obj[iterator_obj] : iterator_obj;
if (list_obj_isarray || iterator_obj!="__dummyKey") { if (obj.parent == _obj281.pov.parent && !(DoesInherit(obj, "npc_type"))) {
listadd (_obj281.pov.currentcommandpendingobjectscope, obj);
} }
} },
"script": function(parameters) { var object = parameters['object'];
var multiple = parameters['multiple'];
if (multiple && ListCount(object) == 0) {
OutputText ("Nothing here to take.");
}
else {
var object_isarray = (Object.prototype.toString.call(object) === '[object Array]');
for (var iterator_obj in object) {
var obj = object_isarray ? object[iterator_obj] : iterator_obj;
if (object_isarray || iterator_obj!="__dummyKey") { DoTake (obj, multiple); }
}
} },
"_js_name": "_obj283",
"_types": ["defaultcommand"]
};
elementsNameMap["take"] = _obj283;
allCommands.push(_obj283);
objectsNameMap["take"] = _obj283;

If I change parameters (which is undefined) to this on these two lines, TAKE works:

"multipleobjects": function(parameters) {var object = this['object'];
var multiple = this['multiple'];

Now, I wonder how to build that in, rather than having to edit the JS file after compiling each game. The "take" object is not in the game.js file until after converting a game. Hrmm...


From the error message, the issue is that multipleobjects is being called without parameters. It does not seem to use them, so it work if you just remove the "parameters" parameter?

What is the relationship between Quest JS and Quest itself? I.e., how do changes in Quest affect QuestJS? What version of QuestJS are you using? Have you got a version you have been editing?


From the error message, the issue is that multipleobjects is being called without parameters. It does not seem to use them, so it work if you just remove the "parameters" parameter?

parameters should be the command object, as far as I can tell. This seems to be true, since changing parameters to this made TAKE and DROP work correctly. (See the end of my first post, in the last code section.)


What is the relationship between Quest JS and Quest itself? I.e., how do changes in Quest affect QuestJS?

QJS has a few functions built in, but only a few.

It (somehow) converts Quest objects, functions, and commands (and such) to JS objects. (I wish I had a clue how this works.)

take, drop, DoTake, and DoDrop are all created during the conversion. They do not exist in QuestJS's code.

This is the 'take' object that is created when converting a Quest 5.7.1 game (and it works; and it has the same code as far as the parameters variable is concerned):


_obj275 = {
    "elementtype": "object",
    "name": "take",
    "type": "command",
    "pattern": "^take (?<object>.*)$|^get (?<g2_map_object>.*)$|^pick up (?<g3_map_object>.*)$",
    "multiple": function() { var takeList = NewObjectList();
        var list_obj = ListExclude(ScopeVisibleNotHeldNotScenery(), _obj273.pov);
        var list_obj_isarray = (Object.prototype.toString.call(list_obj) === '[object Array]');
        for (var iterator_obj in list_obj) {
            var obj = list_obj_isarray ? list_obj[iterator_obj] : iterator_obj;
            if (list_obj_isarray || iterator_obj!="__dummyKey") { if (obj.parent == _obj273.pov.parent) {
                listadd (takeList, obj);
            } }
        }
        return (takeList); },
    "scope": "notheld",
    "script": function(parameters) { var object = parameters['object'];
        var multiple = parameters['multiple'];
        var object_isarray = (Object.prototype.toString.call(object) === '[object Array]');
        for (var iterator_obj in object) {
            var obj = object_isarray ? object[iterator_obj] : iterator_obj;
            if (object_isarray || iterator_obj!="__dummyKey") { DoTake (obj, multiple); }
        } },
    "_js_name": "_obj275",
    "_types": ["defaultcommand"]
};
elementsNameMap["take"] = _obj275;
allCommands.push(_obj275);
objectsNameMap["take"] = _obj275;

So that made be look at the function calling it (of course), which is runscriptattribute2(). This is in the QuestJS code, so I can change it and let it ride (if it doesn't break anything else).

The current runscriptattribute2:

function runscriptattribute2(object, attribute) {
    var fn = GetAttribute(object, attribute);
    fn.call(object);
}

If I change that to this, TAKE and DROP and LOOK will work (but I have only tested those three):

function runscriptattribute2(object, attribute) {
    var fn = GetAttribute(object, attribute);
	fn.call(object, attribute);
}

I wonder what that will break...

Here is the test game with that change:
http://textadventures.co.uk/games/view/qxlugkg_ceo_-lx0m_uxkg/take-test-questjs


What version of QuestJS are you using? Have you got a version you have been editing?

Alex's last version of QuestJS won't compile a game that even loads. It sticks at setCss() which is undefined.

I have added a few JS functions to QuestJS (including setCss()), and I altered the CSS a little bit, but that's all.

The files can be found here: https://github.com/KVonGit/QuestStuff/wiki/QuestJS-Patch-for-Quest-5.6.3

I basically told QuestJS things like NewList() is the same thing as [], and NewDictionary() is {}. Besides that, I added Math and audio stuff.

The CSS changes are just for the jjmenu stuff (the panes, if anyone besides Pixie, mrangel, or Pertex is still reading this).


This topic is now closed. Topics are closed after 60 days of inactivity.

Support

Forums