Quest 6 - Giving rooms custom attributes, and checking them later

Anyone know how I would go about giving a room a custom attribute, and then having it checked later?
For example:

createRoom("testroom", {
	desc:"a cool description",
	foo:"bar",
})

if (game.player.loc.foo != "bar") {
        do stuff
}

...While I'm here, I might as well ask if it's possible to teleport a player to another room, and store their inventory somewhere else when they do so.


game.player.loc will be a string (the name of the room).

That part would need to be w[game.player.loc].foo.


I saw something on the wiki about teleporting the player, but I can't find it now for the life of me. I can't remember the exact terminology used, but something on that wiki says what function to use when moving the player to a different room during play.


[nevermind]


To move the player, use world.setRoom.
https://github.com/ThePix/QuestJS/wiki/Attributes-for-items#worldsetroomchar-roomname-dir-forced


Thanks. I ended up actually writing my own function to teleport them:

async function teleport(dest) {
	game.player.loc = dest;
	msg(`<b>The ${w[game.player.loc].alias}</b>`);
	msg(w[game.player.loc].desc);
	return true;
}

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

Support

Forums