Quest 6: Function For Creating Exits

Hello,
Sorry in advance if this is in the wrong forum.
I am wondering if there is a function in Quest 6 similar to the create exit() function in Quest 5.


No there is not. The reason is how games are saved. Any exit that is created during play will not be saved.

There will be ways to work around that. What are you trying to do?


I am attempting to create a sort of open-world game with infinite amounts of rooms that are cloned.


The way to do this would be not using exits at all. QuestJs does it all through the room, so for example it will use the room's "getExit" to get the exit attribute. You can give your rooms their own "getExit", that instead returns an exit on the fly.

I will have a think about this, and say more later, probably in the docs, but it may be a week or so.


As a first stab, something like this - but I have not tried it at all, so likely to need some tweaking!:

createRoom('room_prototype', {
  getExit:function(dir) {
    if (this['exit_' + dir] === undefined) return undefined
    return new Exit(this['exit_' + dir], {origin:this, dir:dir})
  },
  
  hasExit:function(dir, options) {
    if (options === undefined) options = {}
    if (!this['exit_' + dir]) return false
    if (options.excludeLocked && this.isExitLocked(dir)) return false
    return !this.isExitHidden(dir)
  },
  
  findExit:function(dest, options) {
    if (typeof dest === "object") dest = dest.name;
    for (let exit of lang.exit_list) {
      if (this.hasExit(exit.name, options) && this['exit_' + dir] === dest) {
        return this[exit.name];
      }
    }
    return null;
  },
}

Updated. See the docs here:
https://github.com/ThePix/QuestJS/wiki/Creating-objects-on-the-fly#cloning-rooms

You will need the most recent version of _templates, _defaults and _world from Github.


Thank you!


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

Support

Forums