It's all in the Commands - Assistance with commands please

Hey, I am creating a command to handle a thrown item. this is what I have so far:

commands.unshift(new Cmd('Throw',{
	regex:/^(?:throw|toss|chuck) (.+) (?:at|through|on|over|under|out) (.+)$/,
	objects:[
		{scope:parser.isHeld},
		{scope:parser.isPresent},
	],
	
	script:function(objects) {
		return handleThrowAt(game.player, objects)
	},
}))

function handleThrowAt(char, objects) {
	let success = false
	const throwThis = objects[0][0]
	const atThis = objects[1][0]
	
	msg(throwThis.name)
	msg(atThis.name)
	if(throwThis.name === 'oldest_wire_cutters') {
		if(atThis.name === 'broken_window') {
			if(w.boards.boardsOpen) {
				msg("Response string here")
				w.oldest_wire_cutters.loc = 'backyard'
				success = true
			}
		}
	}
	
	if(!success) msg("Failed response string");
	return success ? world.SUCCESS : world.FAILED;
}

the code is created in the code.js module.

Not sure but there could be issues with the documents on this page https://github.com/ThePix/QuestJS/wiki/Creating-Commands

Example: I was not able to get this to work:

return success ? SUCCESS : FAILED;

For this example I am told that FAILED is not defined. When I changed it to this however, it worked:

return success ? world.SUCCESS : world.FAILED;

Thanks,
Steve


Thanks, I realised there were a number of issues with that page due to numerous updates to QuestQR since it was written. Hopefully now resolved.


Log in to post a reply.

Support

Forums