[Solved] How to change the Default Exit attributes?

I want to change the default value for the grid_length( for exits) on the grid map.
I looked into CoreEditorExit.aslx, CoreEditorObjectExits.aslx, and CoreGrid.aslx... but still no clue.

Or a good way to set the attributes when the exits are created. My game object doesn't have any exits now and all exits and most rooms are created on the fly. I thought before I figure where to set these attributes in a convenient way, I should change the default attributes since I'm most likely not gonna change any exit's grid_length ever.


These are the two kinds of events that create exits. I struggled to set the grid_length because I didn't figure out where I can place the script so that it actually works and I forgot what I already tried because nothing worked right when I changed the length.

Both scripts are part of the same type.

  <type name="type_area_rdm">
    <isroom />
    <usedefaultprefix type="boolean">false</usedefaultprefix>
    <objectlistprefix type="string"></objectlistprefix>
    <attr name="coord_x" type="int">0</attr>
    <attr name="coord_y" type="int">0</attr>
    <beforefirstenter type="script">
      // ##############################################################################
      // ______________________________________________________________________________
      // CHECKS IF the room to the NORTH is already created and creates it if not
      // ______________________________________________________________________________
      // ##############################################################################
      gen_n = true
      foreach (ar, GetDirectChildren(zWorldmap)) {
        // ______________________________________________________________________________
        // CHECK X/Y Coords
        // ______________________________________________________________________________
        if (ar.coord_y = this.coord_y + 1 and ar.coord_x = this.coord_x) {
          gen_n = false
          foreach (xt, FilterByAttribute (ScopeExitsForRoom(this), "alias", "north")) {
            RemoveObject (xt)
          }
          foreach (xt, FilterByAttribute (ScopeExitsForRoom(ar), "alias", "south")) {
            RemoveObject (xt)
          }
          create exit ("north", this, ar, "northdirection")
          create exit ("south", ar, this, "southdirection")
        }
      }
      // ______________________________________________________________________________
      // CREATE/CLONE a RANDOM ROOM for the world map.
      // ______________________________________________________________________________
      if (gen_n = true) {
        game.world_gen = "north"
        CloneObjectAndMove (PickOneObject(GetDirectChildren(zVault_World_rdm)), zWorldmap)
      }
    </changedhasbeenmoved>
    <attr name="gen_north" type="script">
      this.coord_x = player.parent.coord_x
      this.coord_y = player.parent.coord_y + 1
      create exit ("north", player.parent, this, "northdirection")
      create exit ("south", this, player.parent, "southdirection")
      game.gen = "-"
    </attr>

If you want to set it for all exits, you should modify the type defaultexit, which is found in CoreTypes.aslx.

By default it looks like this:

  <type name="defaultexit">
    <displayverbs type="simplestringlist">[GoTo]</displayverbs>
    <visible type="boolean">true</visible>
    <scenery type="boolean">false</scenery>
    <locked type="boolean">false</locked>
    <lockmessage>[LockedExit]</lockmessage>
    <lookonly type="boolean">false</lookonly>
    <runscript type="boolean">false</runscript>
    <lightstrength type="string"></lightstrength>
    <grid_length type="int">1</grid_length>
    <grid_render type="boolean">false</grid_render>
    <grid_offset_x type="int">0</grid_offset_x>
    <grid_offset_y type="int">0</grid_offset_y>
  </type>

If you want to modify it, you'll want to copy that into your own game (unless you want to modify all games).

If you want to change the length of dynamically created exits, you'll need to use GetExitByLink (which actually returns the name of the newly created exit, not the exit itself), or GetUniqueElementName.
So instead of:

create exit ("north", player.parent, this, "northdirection")

you would have:

exitname = GetUniqueElementName("exit")
create exit (exitname, "north", player.parent, this, "northdirection")
newexit = GetObject (exitname)
newexit.grid_length = 0

OR

create exit ("north", player.parent, this, "northdirection")
newexit = GetObject (GetExitByLink(player.parent, this))
newexit.grid_length = 0

EDIT

Whoops. mrangel posted while I was typing this, and he knows much more about the grid than I do.


If you want to set it for all exits, you should modify the type defaultexit, which is found in CoreTypes.aslx.

By default it looks like this:

That's it !

If you want to modify it, you'll want to copy that into your own game (unless you want to modify all games).

And this advice is especially helpful.


If you want to change the length of dynamically created exits, you'll need to use GetExitByLink (which actually returns the name of the newly created exit, not the exit itself), or GetUniqueElementName.
So instead of:

I don't understand what sort of advantage your second example offers.


Is it correct if I paste this as a normal type? (There where all my other created types are)

  <type name="defaultexit">
    <displayverbs type="simplestringlist">[GoTo]</displayverbs>
    <visible type="boolean">true</visible>
    <scenery type="boolean">false</scenery>
    <locked type="boolean">false</locked>
    <lockmessage>[LockedExit]</lockmessage>
    <lookonly type="boolean">false</lookonly>
    <runscript type="boolean">true</runscript>
    <lightstrength type="string"></lightstrength>
    <grid_length type="int">0</grid_length>
    <grid_render type="boolean">true</grid_render>
    <grid_offset_x type="int">0</grid_offset_x>
    <grid_offset_y type="int">0</grid_offset_y>
  </type>

EDIT: Okay, I can't create a new defaultexit type like usual.
"An element called 'defaultexit' already exists in this game."


EDIT2:
I solved it. Found this documentation entry about how to make editable copies of the core elements: http://docs.textadventures.co.uk/quest/overriding.html


I don't use the desktop editor, so haven't had much experience with the UI. On previous discussions, I've seen people saying that for types it is often easier to paste them directly into the full code view; but don't know the details.

And I realised after going to bed last night that there's probably a slightly simpler way to do what you want. Instead of replacing defaultexit, you can add your attribute to either either direction or compassdirection. (exits that don't inherit these two types don't appear on the map anyway). The default versions for those are shorter, so take up less space in your game file. The core versions are:

  <type name="direction">
    <displayverbs type="simplestringlist">[Go]</displayverbs>
  </type>

  <type name="compassdirection">
    <inherit name="direction"/>
    <prefix type="string">[CompassDirectionPrefix]</prefix>
    <suffix type="string">[CompassDirectionSuffix]</suffix>
  </type>

I don't understand what sort of advantage your second example offers.

You asked two questions: how to change the default attributes of exits, and how to change an attribute when a script is creating an exit. I answered both.

You probably only need one of those answers if you want the attribute set for all exits. But the script version is still useful if you ever decide make an exception; or if you decide you want to change some other attribute of the exits you're creating.

I've actually tweaked one of the core functions to make creating and messing with exits in script easier. Don't know if it would be useful to you

Just so that you can do CreateBiExits ("north", room1, room2) and have it create the exit in the other direction automatically (the default CreateBiExits breaks the grid map), and also so that if an exit is moved/locked/unlocked, it will affect both sides of it.

  <function name="CreateBiExits" parameters="dir, from, to">
    exitname = GetUniqueElementName("exit")
    revdir = ReverseDirection(dir)
    if (revdir = dir) {
      create exit (exitname, dir, from, to, "defaultexit")
      create exit (exitname+"back", dir, to, from, "defaultexit")
    }
    else {
      create exit (exitname, dir, from, to, dir+"direction")
      create exit (exitname+"back", revdir, to, from, revdir+"direction")
    }
    exit1 = GetObject (exitname)
    exit2 = GetObject (exitname+"back")
    exit1.back = exit2
    exit2.back = exit1
    exit1.changedlocked => {
      this.back.locked = this.locked
    }
    exit1.changedvisible => {
      this.back.visible = this.visible
    }
    exit1.changedparent => {
      this.back.to = this.parent
    }
    exit1.changedto => {
      this.back.parent = this.to
    }
    exit2.changedlocked = exit1.changedlocked
    exit2.changedvisible = exit1.changedvisible
    exit2.changedparent = exit1.changedparent
    exit2.changedto = exit1.changedto
  </function>

The built-in function to create two one-way exits are quite effortless in this case.

[...]and how to change an attribute when a script is creating an exit.

exitname = GetUniqueElementName("exit")
create exit (exitname, "north", player.parent, this, "northdirection")
newexit = GetObject (exitname)
newexit.grid_length = 0

Yes, I got this part now. I didn't understand it at first and it's good to know for probably any sort of created objects which may come up in the future.


One more thing related to exits is still bugging me. I would like to set the exit's link color based on their .to object(room). All rooms have color attributes stored for multiple purposes that are related to their type. Is it possible to change an exit's link color based on a .to object's attribute?

Edit: Is changing the exit link color even possible? ^^


Log in to post a reply.

Support

Forums