Moving a spaceship

J_H_Bailey
19 Feb 2018, 02:03

I'm not a "code" person so I'm having my doubts that this can be done through the GUI.
You have a spaceship on Planet A. You can go out to the space dock or in to the ship's airlock.
Once in the ship you want to fly the entire thing (maybe 5-10 rooms encompassing the ship) to Planet B. Now when you go out the airlock you want to be on the space dock of Planet B.

Overall, I'm enjoying playing around with Quest. I'm not so much a game writer as I am an environment builder. For example, I have mapped out pretty much all of Gotham City including the entire Wayne Manor. But don't have a story to plug in to it.

Thanks for any help.


K.V.
19 Feb 2018, 03:14

Hello.

The easiest thing would probably be providing an example game.


Click details to view the code.

<!--Saved by Quest 5.7.6606.27193-->
<asl version="550">
  <include ref="English.aslx" />
  <include ref="Core.aslx" />
  <game name="From Planet A to Planet B">
    <gameid>4fd65ae8-2209-44b5-b3cc-adfbe9648b95</gameid>
    <version>1.0</version>
    <firstpublished>2018</firstpublished>
  </game>
  <object name="Planet A">
    <inherit name="editor_room" />
    <isroom />
    <object name="player">
      <inherit name="editor_object" />
      <inherit name="editor_player" />
    </object>
    <object name="SpaceshipA">
      <getinto type="script">
        MoveObject (player, Spaceship)
      </getinto>
      <alias>Spaceship</alias>
      <description><![CDATA[You are currently on Planet A.<br/><br/>You can {command:FLY TO PLANET B}.]]></description>
      <look>A nice, shiny spaceship.</look>
      <displayverbs type="stringlist">
        <value>Look at</value>
      </displayverbs>
      <command name="fly_to_cmd">
        <pattern>fly to #text#</pattern>
        <script>
          FlyFunction (text)
        </script>
      </command>
      <exit alias="out" to="Planet A">
        <inherit name="outdirection" />
      </exit>
    </object>
    <exit alias="in" to="SpaceshipA">
      <inherit name="indirection" />
    </exit>
  </object>
  <object name="Planet B">
    <inherit name="editor_room" />
    <object name="SpaceshipB">
      <getinto type="script">
        MoveObject (, )
      </getinto>
      <alias>Spaceship</alias>
      <description><![CDATA[You are currently on Planet B.<br/><br/>You can {command:FLY TO PLANET A}.]]></description>
      <look>A nice, shiny spaceship.</look>
      <command name="fly_to_cmd1">
        <pattern>fly to #text#</pattern>
        <script>
          FlyFunction (text)
        </script>
      </command>
      <exit alias="out" to="Planet B">
        <inherit name="outdirection" />
      </exit>
    </object>
    <exit alias="in" to="SpaceshipB">
      <inherit name="indirection" />
    </exit>
  </object>
  <verb>
    <property>getinto</property>
    <pattern>get into</pattern>
    <defaultexpression>"You can't get into " + object.article + "."</defaultexpression>
  </verb>
  <function name="FlyFunction" parameters="text">
    if (LCase(text) = "planet a") {
      if (player.parent = SpaceshipA) {
        msg ("You are already there.")
      }
      else {
        MoveObject (player, SpaceshipA)
      }
    }
    else if (LCase(text) = "planet b") {
      if (player.parent = SpaceshipB) {
        msg ("You are already there.")
      }
      else {
        MoveObject (player, SpaceshipB)
      }
    }
    else {
      msg ("I didn't understand your command.")
    }
  </function>
</asl>


You can download this, open it up, and look around at everything.

Right-click this link, then select "Save Link As" to download it:

From Planet A to Planet B


Basically, I made two spaceships, and I move the player to a different ship when he or she enters FLY TO PLANET A or FLY TO PLANET B.

It's a very rough example, but it's the easiest way to do it if you want to be able to enter and exit the ship without a lot of extra coding.


J_H_Bailey
19 Feb 2018, 03:43

That's quite interesting. I'm going to play around with that.
Thanks


mrangel
19 Feb 2018, 09:21

Basically, I made two spaceships, and I move the player to a different ship when he or she enters FLY TO PLANET A or FLY TO PLANET B.

That seems like it could lead to issues if the player puts objects on the ship, or if there's any other parts of the ship with more complex behaviour. You'd have to be careful that, for example, both ships are affected if some event can damage the ship, and make sure that all objects inside the ship are moved over.

I'd think it might be more efficient to just move the exit. That is, give a name to the exit that leads from the ship's airlock to the landing field, and the exit that goes in the opposite direction. Then you could do something like:

MoveObject (ship_incoming_exit, planetB_landing_field)
ship_outgoing_exit.to = planetB_landing_field

(Yes, I know that's the opposite of what I'd suggest for a lift. But if the ship is multiple rooms, it seems the simpler choice)


K.V.
20 Feb 2018, 08:08

How about this one?

<!--Saved by Quest 5.7.6606.27193-->
<asl version="550">
  <include ref="English.aslx" />
  <include ref="Core.aslx" />
  <game name="Space Travel">
    <gameid>683034e8-7b68-438c-9fe8-4eab0959fee9</gameid>
    <version>0.0.2</version>
    <firstpublished>2018</firstpublished>
    <gridmap />
    <attr name="autodescription_youarein_useprefix" type="boolean">false</attr>
    <attr name="autodescription_description" type="int">2</attr>
    <attr name="autodescription_youcango" type="int">4</attr>
    <attr name="autodescription_youcansee" type="int">3</attr>
    <description>A Quest adventure.</description>
    <author>K.V.</author>
  </game>
  <object name="Earth Spaceport">
    <inherit name="editor_room" />
    <usedefaultprefix type="boolean">false</usedefaultprefix>
    <prefix>the</prefix>
    <object name="Spaceship">
      <grid_render />
      <grid_parent_offset_auto />
      <feature_startscript />
      <attr name="_initialise_" type="script">
        AddDestination (this, Earth Spaceport)
        AddDestination (this, Moon Spaceport)
      </attr>
      <board type="script">
        MoveObject (game.pov, this)
      </board>
      <description>Enter {command:TRAVEL} to go somewhere.</description>
      <usedefaultprefix type="boolean">false</usedefaultprefix>
      <displayverbs type="stringlist">
        <value>Look at</value>
      </displayverbs>
      <command name="travel_cmd">
        <pattern>travel;fly</pattern>
        <script>
          ShowDestinationMenu
        </script>
      </command>
      <command name="disembark_cmd">
        <pattern>exit;disembark</pattern>
        <script>
          MoveObject (game.pov, game.pov.parent.parent)
        </script>
      </command>
      <exit name="ship_out" alias="out" to="Earth Spaceport">
        <inherit name="outdirection" />
      </exit>
    </object>
    <object name="player">
      <inherit name="editor_object" />
      <inherit name="editor_player" />
    </object>
    <exit alias="north" to="Earth">
      <inherit name="northdirection" />
    </exit>
    <exit name="ship_in" alias="in" to="Spaceship">
      <inherit name="indirection" />
    </exit>
  </object>
  <object name="Moon Spaceport">
    <inherit name="editor_room" />
    <usedefaultprefix type="boolean">false</usedefaultprefix>
    <prefix>the</prefix>
    <exit alias="south" to="Moon">
      <inherit name="southdirection" />
    </exit>
  </object>
  <verb>
    <property>board</property>
    <pattern>board</pattern>
    <defaultexpression>"You can't board " + object.article + "."</defaultexpression>
  </verb>
  <object name="Earth">
    <inherit name="editor_room" />
    <usedefaultprefix type="boolean">false</usedefaultprefix>
    <exit alias="south" to="Earth Spaceport">
      <inherit name="southdirection" />
    </exit>
  </object>
  <object name="Moon">
    <inherit name="editor_room" />
    <usedefaultprefix type="boolean">false</usedefaultprefix>
    <exit alias="north" to="Moon Spaceport">
      <inherit name="northdirection" />
    </exit>
  </object>
  <function name="AddDestination" parameters="ship, destination">
    if (not HasAttribute(ship,"destinations")) {
      ship.destinations = NewObjectList()
    }
    list add (ship.destinations, destination)
  </function>
  <function name="GetDestinations" parameters="ship" type="objectlist">
    return (ListExclude(ship.destinations,ship.parent))
  </function>
  <function name="ShowDestinationMenu">
    ShowMenu ("Where would you like to go?", GetDestinations(game.pov.parent), true) {
      TravelTo (game.pov.parent, GetObject(result))
    }
  </function>
  <function name="TravelTo" parameters="ship, to">
    from = game.pov.parent.parent
    set (game.pov, "saved_map_for_" + from.name, game.pov.grid_coordinates)
    if (HasAttribute(game.pov, "saved_map_for_" + to.name)) {
      game.pov.grid_coordinates = GetAttribute(game.pov, "saved_map_for_" + to.name)
    }
    else {
      game.pov.grid_coordinates = null
    }
    game.pov.parent.parent = to
    JS.Grid_ClearAllLayers ()
    Grid_Redraw
    Grid_DrawPlayerInRoom (game.pov.parent)
    ship_out.to = to
    ship_in.parent = to
    msg ("Time passes.  Eventually, you arrive at " + GetDisplayName(to) + ".")
    ShowRoomDescription
  </function>
</asl>

http://textadventures.co.uk/games/view/mqraxurofkkmfcfnhxaxww/space-travel


J_H_Bailey
20 Feb 2018, 20:22

Yes, the spaceship has more than one room and a few NPC's that would have to go with the ship.

I was also wondering if I could use some sort of IF/THEN routine to move the player to a different location when he left the spaceship. I will have to play around with that idea.

It seems to me that there are often different viable solutions to things with Quest and its just a matter of finding what works for you.

Again, thanks for all the suggestions. I don't think my adventure will ever see the light of day; I'm just trying to learn to do things with Quest.


hegemonkhan
20 Feb 2018, 20:50

if you want to learn coding, we'd be happy to help, as quest makes it/coding really (relatively) easy, as while you CAN do everything via the GUI/Editor, being able to code makes it so much faster (and easier) for you to do whatever you want in your game. Here's some links if you're interested:

http://textadventures.co.uk/forum/quest/topic/mu7itzjqv0yxrkdwgsbmzg/how-to-make-npc-confront-you-with-chioces#46cdb25b-4767-40a6-8bf4-3cd84e805781

http://textadventures.co.uk/forum/samples/topic/5559/attributes-and-if-script-guide-by-hk

I myself found quest knowing nothing of coding at all, and through quest, I'm now taking programming classes at college towards a degree in programming, so I can personally attest to that quest is a great way to learn to code, hehe.

If you want to see my own struggle at learning to code when I first found quest:

https://textadventures.co.uk/forum/quest/topic/3348/noobie-hks-help-me-thread

it's a good laugh in hindsight, but it was a struggle back then, laughs. Though it shows how far I've come/learned, since then, lol


jmnevil54
20 Feb 2018, 23:15

Rooms and objects are the same, just with different properties. Just by moving the rooms around or messing with the exits, you can put multiple rooms in an object. I would just edit the exits to those rooms, you can make an object an exit. But you may want to actually put the rooms in that object.


mrangel
21 Feb 2018, 00:23

I think the way I'd likely do it is by having a spaceship object that can be looked at from the outside ("It's a spaceship, just sitting there on the landing pad"), and similar things.

Then you could have the ship's changedparent script move the ship's exit to the same place as the ship. Something like ship_exit_in.parent = this.parent and ship_exit_out.to = this.parent to move the two sides of the exit. That means that wherever the ship is, players will be able to enter and exit it. (if an object has a script attribute named "changedparent", it will be run whenever the object is moved. So in any other script or command, you could just do MoveObject(ship, martian landing field) or similar, and everything will work)


hegemonkhan
21 Feb 2018, 00:26

(filler for getting my edited post, updated/posted)


The various/differing Attributes that Objects get, either: (1) within just the GUI/Editor (meaning that you can NOT reference/use them, which are the 'editor_XXX' ones, in/for your scripting) or (2) within the entire game (aka: within/during actual game playing), is controlled by the 'core.aslx' Object Types / Inherited Attributes: see link below

http://docs.textadventures.co.uk/quest/elements/object.html (scroll down to the very bottom section 'object types defined by core.asl', to see how Objects are given their various/differing Attributes, however it's missing the 'editor_player' Inherited Attribute / Object Type, and also note that the: 'editor_XXX': 'editor_player', 'editor_room', and 'editor_object', are all only for the GUI/Editor only, they don't exist within your actual game as they're destroyed upon playing your game, so don't try to reference/use them within any scripting, you'll have to make your own way of indicating/flagging for your scriptings' referencing/using, for example, you can create your own 'room_type' Object Type and reference/use it via its 'room_type' Inherited Attribute, or you can just use for example a string attribute, for example: NAME_of_ROOM_OBJECT.type_of_object = "room")

this is also why working with 'doors/containers/etc' opening/closing/locking/unlocking/etc can be so confusing and difficult... lol, there's a lot of built-in scripting, and also it depends upon what built-in 'Inherited Attribute(s) / Object Type(s)' you're using, (and understanding what and/or how they do what they do, lol)as well, lol.


K.V.
21 Feb 2018, 00:32

I think the way I'd likely do it is by having a spaceship object that can be looked at from the outside ("It's a spaceship, just sitting there on the landing pad"), and similar things.

Then you could have the ship's changedparent script move the ship's exit to the same place as the ship. Something like ship_exit_in.parent = this.parent and ship_exit_out.to = this.parent to move the two sides of the exit. That means that wherever the ship is, players will be able to enter and exit it. (if an object has a script attribute named "changedparent", it will be run whenever the object is moved. So in any other script or command, you could just do MoveObject(ship, martian landing field) or similar, and everything will work)

That's what this does (I think):

http://textadventures.co.uk/forum/quest/topic/gbdngp-0h06y8t6i3lwv5w/moving-a-spaceship#9eb5ceaa-043c-4790-b412-9f37e22acdd2

...and it saves and resets the map when you move the ship, too.


hegemonkhan
21 Feb 2018, 00:37

@ J.H.Bailey (and MrAngel and KV):

this isn't for J.H.Bailey 's usage (unless you guys/girls want to make such a library for him/her: probably am referring to KV, who's working his way on being pixie's rival in library making, lol, though mrangel does make some libraries too, lol/meh), as it uses a bit of more advanced coding to handle it, but I'd personally have a 'root container' Object as the 'spaceship', and have the spaceship's chambers/sectors/areas/etc be nested Objects within the 'root container' Object, as this way the entire spaceship (the 'space ship' and its 'sub-areas') can be moved easily (via moving the 'spaceship' root container Object), though again, you'll need some scripting to handle it's various aspects (such as entering/exiting it, and/or amongst: outside rooms vs 'spaceship' root container vs 'sub-areas' within the root container) working correctly.


mrangel
21 Feb 2018, 01:11

That's what this does (I think):

Not quite. Your travel function is quite complex.
I was specifically suggesting that the exit-moving code should be in the ship's changedparent script. That way, whether the player's navigating from the menu, or some in-game event causes the ship to be moved to a different field, the exits will be in the right place.

The code to save and restore the map seems a pretty neat idea. But I think at present it has a few weaknesses. The initial question was about a ship with multiple rooms inside it, so you can't assume that game.pov.parent is the ship. It also means that in a multi-room ship, the rooms within the ship would have to be explored once per planet to make them appear on the map.
I was about to suggest something more complex, but then realised that if you're using the ship's changedparent method to do the legwork, you can use "this" to refer to the ship. If the rooms are nested inside the ship, then (if I remember the map data format correctly) you could have the changedparent script:

  this.airlock_exit_out.to = this.parent
  this.airlock_exit_in.parent = this.parent
  if (game.gridmap) {
    oldmap = game.pov.grid_coordinates
    shiprooms = GetAllChildObjects(this) + this
    if (Contains(this, game.pov)) {
      set (game.pov, "saved_map_for_" + oldvalue.name, oldmap)
      if (HasAttribute(game.pov, "saved_map_for_" + this.parent.name)) {
        game.pov.grid_coordinates = GetAttribute(game.pov, "saved_map_for_" + this.parent.name)
      }
      else {
        game.pov.grid_coordinates = null
      }
      foreach (room, shiprooms) {
        if (DictionaryContains (oldmap, room.name)) {
          if (not DictionaryContains (game.pov.grid_coordinates, room.name)) {
            dictionary add (game.pov.grid_coordinates, room.name, DictionaryItem(oldmap, room.name))
            dictionary remove (oldmap, room.name)
          }
        }
      }
      JS.Grid_ClearAllLayers ()
      Grid_Redraw
      Grid_DrawPlayerInRoom (game.pov.parent)
    }
  }

OK ... super inelegant.
If the ship is stolen by an NPC while the player isn't aboard, its rooms should be removed from the map; or moved to the "saved_map_for_" dictionary even if the player currently isn't there. This will also get confused if there are multiple ships; but I think that's an issue that can currently occur too easily with the map system. I think I can see a way around it, but…
I was interrupted in the middle of typing this post, but will try to remember to come back later.


K.V.
21 Feb 2018, 01:24

I was specifically suggesting that the exit-moving code should be in the ship's changedparent script. That way, whether the player's navigating from the menu, or some in-game event causes the ship to be moved to a different field, the exits will be in the right place.

Ah!

So I see!

The code to save and restore the map seems a pretty neat idea. But...

Man, I wish I'd have thought about all those possibilities!

(I'm also glad you knew I was seriously asking if that's what my script did, rather than thinking I was being unpleasant.)


When I posted that code I was thinking it would take much more than an alias change to add rooms inside of the ship and have it all still work, but...

Somebody stealing the ship or the ship being sent off-course?

That, my good sir, is thinking ahead! (Well played!)


hegemonkhan
21 Feb 2018, 01:29

just a quick comment:

Jay dealt with the 'visible' issue with maps, by simply having a script iterate (foreach) through all of the rooms, setting their 'visible' to 'true', so they show up and work with the (I think also newly/re drawn) map, before you then are able to move/do stuff as a user playing the game


mrangel
21 Feb 2018, 01:40

(My thought for the map system was that rather than "saved_map_for_", we could have a list of saved disjoint maps. Any time the player teleports to a room with no coordinates, by whatever means, the grid system should add the current map to the list and start a new one. Modify the functions that initially set map coordinates for a new room so that they first check if that room exists in any of the other maps in the list. If it does, then compare its coordinates to find the x, y, and z offsets between the two maps, and copy all rooms from that disjoint map into the current one, adding the differences onto their coordinates as you do so. If the grid system worked like this, then the spaceship code could specifically override it by forcing the ship and its rooms into a separate map when it launches. When it lands again, as soon as the player walks out of the airlock, the same system would glue the map back together automatically)


K.V.
21 Feb 2018, 01:46

Jay dealt with the 'visible' issue with maps, by simply having a script iterate (foreach) through all of the rooms, setting their 'visible' to 'true', so they show up and work with the (I think also newly/re drawn) map, before you then are able to move/do stuff as a user playing the game

I think that needs all the rooms to be connected, but I may be thinking of something else.

(I think you're referencing the teleportation stuff here: http://docs.textadventures.co.uk/quest/showing_a_map.html)


I'm thinking (now) that the best method would be having a separate map for when you are in the spaceship. It would simply display the rooms you have visited inside of the ship.

This would involve saving the current map to an attribute, then resetting the map, then loading the map with saved map from each different region: the ship and the worlds to which you can travel. That's what my last example game already does, sans making the ship a region of its own (complete with rooms inside).

Combining mrangel's method (the changedparent script on the ship) with the other stuff I've got would probably work quite well.


K.V.
21 Feb 2018, 02:17

My thought for the map system was that rather than "saved_map_for_", we could have a list of saved disjoint maps. Any time the player teleports...

See, there you went.

Directly over my head and beyond me (in a good way).

I mean, I think I know what you mean (and it sounds splendid), but the coordinate functions are currently my least favorite functions. (I may just be trying to make it all more complicated than it actually is.)

Doesn't that already save maps, then create new maps or load existing maps, whichever is necessary?

It is set on game.pov, but we could switch it to the ship object? (Is that part of what you mean, mrangel?)


K.V.
21 Feb 2018, 02:32

Here's an old post from HK, linking to cool mapping code:
http://textadventures.co.uk/forum/quest/topic/czwi-rm_6e6ovfp86ubipa/exit-a-moving-room#f4916645-ed9d-4e6f-b1e4-4e181e5a4648


hegemonkhan
21 Feb 2018, 03:06

well, the iterating (visible = true) would just be for THAT 'map' section, to create THAT map section, if you have a bunch of "map sections".

the ship should be a "map section" (specific interior cell), you'd only see THAT map section (the ship's rooms)


usually the design is this:

  1. a "world" map (one large connected 'exterior' cell)
    and
  2. 'interior' cells/maps (a town, dungeon, ship, sub-sections of the world, etc), where'd you just see that specific interior cell/map, and not anything else, including not other interior cells/maps

movement can occur between:

  1. "world/exterior" map/cell and a specific interior cell/map
  2. specific interior cell/map and specific interior cell/map

(if you want it even more complex/organized):

  1. specific "world/exterior" map/cell and specific "world/exterior" map/cell // (having multiple "worlds or sub-world sections of a single world")

and...

  1. have a list storing all rooms (for each "map section"/cell)

  2. have a list for storing visited (explored by you) rooms (for each "map section"/cell), that way you can use it to redraw that map of areas you explored, as you enter and leave those map sections, which you can adjust (adding/removing from list, now you'd probably not want to remove an explored area... unless you want a permanantly "dark/invisible" room, such as in the original zelda game for the NES, hehe)


K.V.
21 Feb 2018, 04:16

I see what you mean, HK.

All that stuff works fine. I think the code I used (and barely modified) originally came from Jay.

I just made an example game with a one-room ship, with a map that works just like you describe when you travel to different worlds.

I got side-tracked, you see. The OP wanted numerous rooms inside of the ship. Then, mrangel mentioned a few ways the ship could be thrown off course without the TRAVEL command being entered, which would require a map update.

As far as the TRAVEL command goes, I can just change game.pov.parent to game.pov.current_ship to move the current ship (which would be set up as an object attribute).

Then, the actual mapping functions would be called from the ship's changedparent script (rather than from the TRAVEL command's script), and there would be a map for each region (and maybe each dimension).

So, it should work pretty much just like you're saying with only a few minor adjustments.


K.V.
21 Feb 2018, 04:18

PS

I think only a map of the ship should be displayed when inside of it.

Different trips would take different amounts of turns, too.

Also, I think including this would be awesome:
https://textadventures.co.uk/forum/samples/topic/5875/creating-images-on-the-fly

http://textadventures.co.uk/games/view/ohqyc_lfuuiqjsuwmvbkbw/star-empire-v0-1


K.V.
21 Feb 2018, 22:40

Rooms in the spaceship

If memory serves, the Heart of Gold in The Hitchhiker's Guide to the Galaxy was set up like this:

image


This layout would require modification in an actual game, I'm sure, but something like this should be pretty easy.

Everything besides the Ramp would be in a map by itself.

The ramp would be moved to wherever the ship travels. So the Hatchway would always exit down to the Ramp and vice-versa, but the Ramp would be the only object that actual changed parent objects. It would have an exit to the south, also, which was changed to the Ramp's current parent in the ramp.changedparent script.

When the player moved from the Hatchway to the Ramp, the map would switch to the current location. The only room of the ship which would be displayed on the map would be the Ramp.

(I think this is pretty much what mrangel was suggesting, too.)


Slightly Off-topic

Now, you see how I made that map in Trizbort?

Well, that isn't the current release of Trizbort. It is what you get if you build what's currently in the repository on GitHub, though.

...and it can do this:

image

...which allows me to immediately paste this from my clipboard:

The code from Trizbort's export:

  <object name="CorridorAftEnd">
    <inherit name="editor_room" />
    <alias>Corridor Aft End</alias>
    <attr name="grid_width" type="int">2</attr>
    <attr name="grid_length" type="int">2</attr>
    <attr name="grid_fill">Transparent</attr>
    <attr name="grid_border">Transparent</attr>
    <attr name="implementation_notes"></attr>
    <exit alias="north" to="CorridorForeEnd">
      <inherit name="northdirection" />
    </exit>
    <exit alias="south" to="EngineRoom">
      <inherit name="southdirection" />
    </exit>
    <exit alias="west" to="Pantry">
      <inherit name="westdirection" />
    </exit>
    <exit alias="down" to="Hatchway">
      <inherit name="downdirection" />
    </exit>
  </object>

  <object name="CorridorForeEnd">
    <inherit name="editor_room" />
    <alias>Corridor Fore End</alias>
    <attr name="grid_width" type="int">2</attr>
    <attr name="grid_length" type="int">2</attr>
    <attr name="grid_fill">Transparent</attr>
    <attr name="grid_border">Transparent</attr>
    <attr name="implementation_notes"></attr>
    <exit alias="north" to="EntryBayTwo">
      <inherit name="northdirection" />
    </exit>
    <exit alias="south" to="CorridorAftEnd">
      <inherit name="southdirection" />
    </exit>
    <exit alias="west" to="Galley">
      <inherit name="westdirection" />
    </exit>
    <exit alias="up" to="Bridge">
      <inherit name="updirection" />
    </exit>
  </object>

  <object name="Bridge">
    <inherit name="editor_room" />
    <alias>Bridge</alias>
    <attr name="grid_width" type="int">2</attr>
    <attr name="grid_length" type="int">2</attr>
    <attr name="grid_fill">Transparent</attr>
    <attr name="grid_border">Transparent</attr>
    <attr name="implementation_notes"></attr>
    <exit alias="down" to="CorridorForeEnd">
      <inherit name="downdirection" />
    </exit>
  </object>

  <object name="AccessSpace">
    <inherit name="editor_room" />
    <alias>Access Space</alias>
    <attr name="grid_width" type="int">2</attr>
    <attr name="grid_length" type="int">2</attr>
    <attr name="grid_fill">Transparent</attr>
    <attr name="grid_border">Transparent</attr>
    <attr name="implementation_notes"></attr>
    <exit alias="west" to="Hatchway">
      <inherit name="westdirection" />
    </exit>
  </object>

  <object name="Hatchway">
    <inherit name="editor_room" />
    <alias>Hatchway</alias>
    <attr name="grid_width" type="int">2</attr>
    <attr name="grid_length" type="int">2</attr>
    <attr name="grid_fill">Transparent</attr>
    <attr name="grid_border">Transparent</attr>
    <attr name="implementation_notes"></attr>
    <exit alias="east" to="AccessSpace">
      <inherit name="eastdirection" />
    </exit>
    <exit alias="up" to="CorridorAftEnd">
      <inherit name="updirection" />
    </exit>
    <exit alias="down" to="Ramp">
      <inherit name="downdirection" />
    </exit>
  </object>

  <object name="Galley">
    <inherit name="editor_room" />
    <alias>Galley</alias>
    <attr name="grid_width" type="int">2</attr>
    <attr name="grid_length" type="int">2</attr>
    <attr name="grid_fill">Transparent</attr>
    <attr name="grid_border">Transparent</attr>
    <attr name="implementation_notes"></attr>
    <exit alias="east" to="CorridorForeEnd">
      <inherit name="eastdirection" />
    </exit>
  </object>

  <object name="EntryBayTwo">
    <inherit name="editor_room" />
    <alias>Entry Bay Two</alias>
    <attr name="grid_width" type="int">2</attr>
    <attr name="grid_length" type="int">2</attr>
    <attr name="grid_fill">Transparent</attr>
    <attr name="grid_border">Transparent</attr>
    <attr name="implementation_notes"></attr>
    <exit alias="south" to="CorridorForeEnd">
      <inherit name="southdirection" />
    </exit>
  </object>

  <object name="EngineRoom">
    <inherit name="editor_room" />
    <alias>Engine Room</alias>
    <attr name="grid_width" type="int">2</attr>
    <attr name="grid_length" type="int">2</attr>
    <attr name="grid_fill">Transparent</attr>
    <attr name="grid_border">Transparent</attr>
    <attr name="implementation_notes"></attr>
    <exit alias="north" to="CorridorAftEnd">
      <inherit name="northdirection" />
    </exit>
  </object>

  <object name="Ramp">
    <inherit name="editor_room" />
    <alias>Ramp</alias>
    <attr name="grid_width" type="int">2</attr>
    <attr name="grid_length" type="int">2</attr>
    <attr name="grid_fill">Transparent</attr>
    <attr name="grid_border">Transparent</attr>
    <attr name="implementation_notes"></attr>
    <exit alias="up" to="Hatchway">
      <inherit name="updirection" />
    </exit>
  </object>

  <object name="Pantry">
    <inherit name="editor_room" />
    <alias>Pantry</alias>
    <attr name="grid_width" type="int">2</attr>
    <attr name="grid_length" type="int">2</attr>
    <attr name="grid_fill">Transparent</attr>
    <attr name="grid_border">Transparent</attr>
    <attr name="implementation_notes"></attr>
    <exit alias="east" to="CorridorAftEnd">
      <inherit name="eastdirection" />
    </exit>
  </object>

Now, I can fill in this blank with that code:

<!--Saved by Quest 5.7.6606.27193-->
<asl version="550">
  <include ref="English.aslx" />
  <include ref="Core.aslx" />
  <game name="HOG">
    <gameid>69e39e98-c7cb-4962-a064-6fec0f412d14</gameid>
    <version>1.0</version>
    <firstpublished>2018</firstpublished>
  </game>
  <object name="room">
    <inherit name="editor_room" />
    <object name="player">
      <inherit name="editor_object" />
      <inherit name="editor_player" />
    </object>
    <exit alias="north" to="Ramp">
      <inherit name="northdirection" />
    </exit>
  </object>
  <object name="Heart of Gold">
    <inherit name="editor_room" />

  
  
  <!--
  INSERT CODE FROM TRIZBORT HERE
  -->
  

  </object>
</asl>

...and I've got most of the ship in a game!

image


I only need to polish up a few details, now!

(Like changing the directions to FORE, AFT, PORT, and SB (STARBOARD)!)


K.V.
22 Feb 2018, 04:10

Okay...

Here's what I've got so far:

  • Directions change to FORE/FORWARD,PORT,STARBOARD, and AFT when on board the ship

  • The map seems to work as I was hoping it would

  • The Ramp is in a room by itself, and this will be the only "part of the ship" that moves when travelling

  • There is no travelling functionality yet, but I'll be using things from previous posts in this thread.


CODE: Spacecraft Prototype

<!--Saved by Quest 5.7.6606.27193-->
<asl version="550">
  <include ref="English.aslx" />
  <include ref="Core.aslx" />
  <template name="go_ship"><![CDATA[^go to (?<exit>.*)$|^go (?<exit>.*)$|^(?<exit>forward|port|starboard|aft|f|p|a|s|in|out|up|down|o|u|d)$]]></template>
  <template name="lookdir_ship"><![CDATA[^look (?<exit>forward|port|starboard|aft|f|p|a|s|in|out|up|down|o|u|d)$]]></template>
  <game name="Spacecraft Prototype">
    <gameid>69e39e98-c7cb-4962-a064-6fec0f412d14</gameid>
    <version>1.0</version>
    <firstpublished>2018</firstpublished>
    <gridmap />
    <shipDirs type="stringdictionary">
      <item>
        <key>north</key>
        <value>fore</value>
      </item>
      <item>
        <key>east</key>
        <value>starboard</value>
      </item>
      <item>
        <key>west</key>
        <value>port</value>
      </item>
      <item>
        <key>south</key>
        <value>aft</value>
      </item>
    </shipDirs>
  </game>
  <object name="room">
    <inherit name="editor_room" />
    <object name="player">
      <inherit name="editor_object" />
      <inherit name="editor_player" />
    </object>
    <exit alias="north" to="Ramp">
      <inherit name="northdirection" />
      <attr name="grid_length" type="int">0</attr>
    </exit>
    <object name="Ramp">
      <inherit name="editor_room" />
      <alias>Ramp</alias>
      <attr name="grid_width" type="int">1</attr>
      <attr name="grid_length" type="int">1</attr>
      <attr name="grid_fill">Blue</attr>
      <attr name="grid_border" type="string"></attr>
      <implementation_notes />
      <exit alias="in" to="Ramp">
        <inherit name="indirection" />
        <runscript />
        <attr name="grid_length" type="int">0</attr>
        <script type="script">
          from = game.pov.parent.parent
          to = Hatchway
          set (game.pov, "saved_map_for_" + from.name, game.pov.grid_coordinates)
          if (HasAttribute(game.pov, "saved_map_for_Hatchway")) {
            game.pov.grid_coordinates = GetAttribute(game.pov, "saved_map_for_Hatchway")
          }
          else {
            game.pov.grid_coordinates = null
          }
          game.pov.onboard = true
          JS.eval ("inShip = true;")
          game.pov.parent = Hatchway
          JS.Grid_ClearAllLayers ()
          Grid_Redraw
          Grid_DrawPlayerInRoom (game.pov.parent)
        </script>
      </exit>
      <exit alias="south" to="room">
        <inherit name="southdirection" />
        <attr name="grid_length" type="int">1</attr>
      </exit>
    </object>
  </object>
  <object name="Spacecraft">
    <inherit name="editor_room" />
    <inherit name="ship" />
    <attr name="grid_width" type="int">14</attr>
    <attr name="grid_length" type="int">14</attr>
    <attr name="grid_borderwidth" type="int">0</attr>
    <object name="Pantry">
      <inherit name="editor_room" />
      <alias>Pantry</alias>
      <attr name="grid_width" type="int">1</attr>
      <attr name="grid_length" type="int">1</attr>
      <attr name="grid_fill" type="string"></attr>
      <attr name="grid_border" type="string"></attr>
      <implementation_notes />
      <exit alias="east" to="CorridorAftEnd">
        <inherit name="eastdirection" />
        <alt type="stringlist">
          <value>sb</value>
          <value>starboard</value>
        </alt>
      </exit>
    </object>
    <object name="EngineRoom">
      <inherit name="editor_room" />
      <alias>Engine Room</alias>
      <attr name="grid_width" type="int">1</attr>
      <attr name="grid_length" type="int">1</attr>
      <attr name="grid_fill" type="string"></attr>
      <attr name="grid_border" type="string"></attr>
      <implementation_notes />
      <exit alias="north" to="CorridorAftEnd">
        <inherit name="northdirection" />
        <alt type="stringlist">
          <value>f</value>
          <value>fore</value>
          <value>forward</value>
        </alt>
      </exit>
    </object>
    <object name="EntryBayTwo">
      <inherit name="editor_room" />
      <alias>Entry Bay Two</alias>
      <attr name="grid_width" type="int">1</attr>
      <attr name="grid_length" type="int">1</attr>
      <attr name="grid_fill" type="string"></attr>
      <attr name="grid_border" type="string"></attr>
      <implementation_notes />
      <exit alias="south" to="CorridorForeEnd">
        <inherit name="southdirection" />
        <alt type="stringlist">
          <value>a</value>
          <value>aft</value>
        </alt>
      </exit>
    </object>
    <object name="Galley">
      <inherit name="editor_room" />
      <alias>Galley</alias>
      <attr name="grid_width" type="int">1</attr>
      <attr name="grid_length" type="int">1</attr>
      <attr name="grid_fill" type="string"></attr>
      <attr name="grid_border" type="string"></attr>
      <implementation_notes />
      <exit alias="east" to="CorridorForeEnd">
        <inherit name="eastdirection" />
        <alt type="stringlist">
          <value>sb</value>
          <value>starboard</value>
        </alt>
      </exit>
    </object>
    <object name="Hatchway">
      <inherit name="editor_room" />
      <alias>Hatchway</alias>
      <attr name="grid_width" type="int">1</attr>
      <attr name="grid_length" type="int">1</attr>
      <attr name="grid_fill" type="string"></attr>
      <attr name="grid_border" type="string"></attr>
      <implementation_notes />
      <beforeenter type="script">
        firsttime {
          go.pattern_bak = go.pattern
          lookdir.pattern_bak = lookdir.pattern
        }
        go.pattern = this.parent.regEx
        lookdir.pattern = this.parent.lookdir
      </beforeenter>
      <exit alias="east" to="AccessSpace">
        <inherit name="eastdirection" />
        <alt type="stringlist">
          <value>sb</value>
          <value>starboard</value>
        </alt>
      </exit>
      <exit alias="up" to="CorridorAftEnd">
        <inherit name="updirection" />
        <runscript />
        <script type="script">
          MapUpFrom (game.pov.parent)
          game.pov.parent = this.to
        </script>
      </exit>
      <exit alias="out" to="Hatchway">
        <inherit name="outdirection" />
        <runscript />
        <script type="script">
          game.pov.onboard = false
          from = game.pov.parent
          to = Ramp
          set (game.pov, "saved_map_for_" + from.name, game.pov.grid_coordinates)
          if (HasAttribute(game.pov, "saved_map_for_"+this.to.parent)) {
            game.pov.grid_coordinates = GetAttribute(game.pov, "saved_map_for_"+this.to.parent)
          }
          else {
            game.pov.grid_coordinates = null
          }
          JS.eval ("inShip = false;")
          game.pov.parent = Ramp
          JS.Grid_ClearAllLayers ()
          Grid_Redraw
          Grid_DrawPlayerInRoom (game.pov.parent)
        </script>
      </exit>
    </object>
    <object name="AccessSpace">
      <inherit name="editor_room" />
      <alias>Access Space</alias>
      <attr name="grid_width" type="int">1</attr>
      <attr name="grid_length" type="int">1</attr>
      <attr name="grid_fill" type="string"></attr>
      <attr name="grid_border" type="string"></attr>
      <implementation_notes />
      <exit alias="west" to="Hatchway">
        <inherit name="westdirection" />
        <alt type="stringlist">
          <value>port</value>
          <value>p</value>
        </alt>
      </exit>
    </object>
    <object name="Bridge">
      <inherit name="editor_room" />
      <alias>Bridge</alias>
      <attr name="grid_width" type="int">8</attr>
      <attr name="grid_length" type="int">10</attr>
      <attr name="grid_fill">SteelBlue</attr>
      <attr name="grid_border">Transparent</attr>
      <implementation_notes />
      <exit alias="down" to="CorridorForeEnd">
        <inherit name="downdirection" />
        <runscript />
        <script type="script">
          MapDownFrom (game.pov.parent)
          game.pov.parent = this.to
        </script>
      </exit>
    </object>
    <object name="CorridorForeEnd">
      <inherit name="editor_room" />
      <alias>Corridor, Fore End</alias>
      <attr name="grid_width" type="int">1</attr>
      <attr name="grid_length" type="int">1</attr>
      <attr name="grid_fill" type="string"></attr>
      <attr name="grid_border" type="string"></attr>
      <implementation_notes />
      <exit alias="north" to="EntryBayTwo">
        <inherit name="northdirection" />
        <alt type="stringlist">
          <value>f</value>
          <value>fore</value>
        </alt>
      </exit>
      <exit alias="south" to="CorridorAftEnd">
        <inherit name="southdirection" />
        <alt type="stringlist">
          <value>aft</value>
          <value>a</value>
        </alt>
      </exit>
      <exit alias="west" to="Galley">
        <inherit name="westdirection" />
        <alt type="stringlist">
          <value>p</value>
          <value>port</value>
        </alt>
      </exit>
      <exit alias="up" to="Bridge">
        <inherit name="updirection" />
        <runscript />
        <script type="script">
          MapUpFrom (game.pov.parent)
          game.pov.parent = this.to
        </script>
      </exit>
    </object>
    <object name="CorridorAftEnd">
      <inherit name="editor_room" />
      <alias>Corridor, Aft End</alias>
      <attr name="grid_width" type="int">1</attr>
      <attr name="grid_length" type="int">1</attr>
      <attr name="grid_fill" type="string"></attr>
      <attr name="grid_border" type="string"></attr>
      <implementation_notes />
      <exit alias="north" to="CorridorForeEnd">
        <inherit name="northdirection" />
        <alt type="stringlist">
          <value>f</value>
          <value>fore</value>
        </alt>
      </exit>
      <exit alias="south" to="EngineRoom">
        <inherit name="southdirection" />
        <alt type="stringlist">
          <value>a</value>
          <value>aft</value>
        </alt>
      </exit>
      <exit alias="west" to="Pantry">
        <inherit name="westdirection" />
        <alt type="stringlist">
          <value>p</value>
          <value>port</value>
        </alt>
      </exit>
      <exit alias="down" to="Hatchway">
        <inherit name="downdirection" />
        <runscript />
        <script type="script">
          MapDownFrom (game.pov.parent)
          game.pov.parent = this.to
        </script>
      </exit>
    </object>
  </object>
  <turnscript name="tst">
    <enabled />
    <script>
      JS.sortExits ()
    </script>
  </turnscript>
  <type name="ship">
    <feature_startscript />
    <captain type="object">player</captain>
    <destination type="object">Ramp</destination>
    <attr name="_initialise_" type="script"><![CDATA[
      this.regEx = "^go to (?<exit>.*)$|^go (?<exit>.*)$|^(?<exit>fore|forward|port|starboard|aft|f|p|a|s|in|out|up|down|o|u|d)$"
    ]]></attr>
    <attr name="locations_visited" type="objectlist"></attr>
    <course type="objectlist"></course>
  </type>
  <function name="GetDisplayNameLink" parameters="obj, type" type="string"><![CDATA[
    verbs = GetDisplayVerbs(obj)
    if (verbs <> null) {
      verbCount = ListCount(verbs)
    }
    else {
      verbCount = 0
    }
    if (type = "exit" and verbCount = 1) {
      if (not game.enablehyperlinks) {
        result = GetDisplayAlias(obj)
      }
      else {
        result = "{exit:" + obj.name + "}"
      }
    }
    else if (type = "") {
      result = GetDisplayAlias(obj)
    }
    else {
      result = "{object:" + obj.name + "}"
    }
    if (not GetBoolean(obj, "usedefaultprefix")) {
      if (obj.prefix = null) {
        prefix = ""
      }
      else {
        prefix = obj.prefix
      }
    }
    else if (type = "exit") {
      prefix = ""
    }
    else {
      prefix = GetDefaultPrefix(obj)
    }
    if (LengthOf(prefix) > 0) {
      prefix = prefix + " "
    }
    result = prefix + result
    if (not GetBoolean(obj, "usedefaultprefix") and HasString(obj, "suffix")) {
      if (LengthOf(obj.suffix) > 0) {
        result = result + " " + obj.suffix
      }
    }
    return (result)
  ]]></function>
  <function name="ProcessTextCommand_GetNextLinkId" type="string">
    if (not HasInt(game, "lastlinkid")) {
      game.lastlinkid = 0
    }
    game.lastlinkid = game.lastlinkid + 1
    return ("verblink" + game.lastlinkid)
  </function>
  <function name="ProcessTextCommand_Exit" parameters="section, data" type="string"><![CDATA[
    exitname = Mid(section, 6)
    exit = GetObject(exitname)
    if (exit = null) {
      return ("@@@open@@@" + ProcessTextSection(section, data) + "@@@close@@@")
    }
    else {
      verbs = GetDisplayVerbs(exit)
      alias = GetDisplayAlias(exit)
      command = LCase(StringListItem(verbs, 0)) + " " + alias
      style = GetCurrentLinkTextFormat()
      if (GetBoolean(game.pov,"onboard") and (DictionaryContains(game.shipDirs,alias))) {
        repl = StringDictionaryItem(game.shipDirs,alias)
        alias = repl
        command = "go "+repl
      }
      return ("<a style=\"" + style + "\" class=\"cmdlink exitlink\" data-elementid=\"" + exit.name + "\" data-command=\"" + command + "\">" + alias + "</a>")
    }
  ]]></function>
  <function name="MapUpFrom" parameters="room">
    Grid_SetGridCoordinateForPlayer (game.pov, room, "z", Grid_GetGridCoordinateForPlayer(game.pov, game.pov.parent, "z")+1)
  </function>
  <function name="MapDownFrom" parameters="room">
    Grid_SetGridCoordinateForPlayer (game.pov, game.pov.parent, "z", Grid_GetGridCoordinateForPlayer(game.pov, room, "z")+1)
  </function>
</asl>

TODO:

  • Make a real todo list
  • Sprinkle in the travelling functions, a list of possible destinations, and such from the other example and suggestions in this thread (this one is easy-peasy)
  • Add more attributes on the "ship" type to keep track of the status of numerous things (damage, fuel, power (I'm taking suggestions, too))
  • Come up with all the ways to interact with the ship. (I'm thinking you can talk to the computer. "Computer, set coordinates for Phobos!")
  • (Maybe) Steal the code Pixie uses for the map in his "proof of concept" game and make that one way to plot a course. (The course can be overridden by talking to the computer, and possibly in other ways.)
  • Switch all the attributes and scripts that end up on the ship object to the ship type.
  • Add 'embark;board' verb to the Ramp
  • Make sure everything that needs to keeps track of the ship's faux location at all times!
  • Umm... Other stuff I'm forgetting at the moment. (I need a nap!)

Spacecraft Prototype - Play online