I want to create a game with a display based on rooms with the map.

RagnorokX
12 Dec 2017, 02:58

I have 207 rooms to fit a 23 by 9 grid of rooms on the display. Each one is titled Tile1, Tile2, Tile3, etc. Since this is going to be a display, I need some way to either fit these into lists(23 lists for each of the x columns,) or to create a function that can return the name of the necessary tile with an x and a y value. The only problem is, I have no idea how to combine Tile with a Number to get an object name necessary for either putting the rooms into an object list or for a function to return them. Help?


K.V.
12 Dec 2017, 07:59

Hello.

Something like this? (Check out the debugger after play begins. The rooms each have x_coordinate and y_coordinate, and the game object will have your 23 lists of rooms set up, with 9 rooms on each.

<!--Saved by Quest 5.7.6404.15496-->
<asl version="550">
  <include ref="English.aslx" />
  <include ref="Core.aslx" />
  <game name="Twenty-three BY Nine (207 rooms)">
    <gameid>cd9ae2ea-171e-481e-8eae-e022952ce0b3</gameid>
    <version>1.0</version>
    <firstpublished>2017</firstpublished>
    <start type="script">
      MakeGrids
    </start>
  </game>
  <object name="room">
    <inherit name="editor_room" />
    <enter type="script">
      targetRoom = FindRoom (5, 1)
      msg (targetRoom)
    </enter>
    <object name="player">
      <inherit name="editor_object" />
      <inherit name="editor_player" />
    </object>
  </object>
  <object name="Tile">
    <inherit name="editor_room" />
  </object>
  <function name="MakeGrids"><![CDATA[
    i = 0
    while (i<207) {
      newRoom = CloneObject (Tile)
      newRoom.x_coordinate = i+1
      newRoom.y_coordinate = i/9+1
      nol = NewObjectList()
      // set (game, "room_list"+(i/9+1), nol)
      if (i%9 = 0) {
        newArea = "area"+(i/9+1)
        newArea = NewObjectList()
      }
      list add (newArea, newRoom)
      set (game, "room_list"+(i/9+1), newArea)
      i = i + 1
    }
  ]]></function>
  <function name="FindRoom" parameters="x, y" type="object">
    foreach (obj, AllObjects()) {
      if (HasAttribute(obj, "x_coordinate")) {
        if (x = obj.x_coordinate) {
          if (y = obj.y_coordinate) {
            return (obj)
          }
        }
      }
    }
  </function>
</asl>

image


image


jmnevil54
12 Dec 2017, 17:22

I would just make a string list. But that would be a really long list.
Also, it is possible to get things by their name. "GetObject"...


K.V.
12 Dec 2017, 18:14

Oh, yeah. I put that in there, but forgot to point it out.

The function:

  <function name="FindRoom" parameters="x, y" type="object">
    foreach (obj, AllObjects()) {
      if (HasAttribute(obj, "x_coordinate")) {
        if (x = obj.x_coordinate) {
          if (y = obj.y_coordinate) {
            return (obj)
          }
        }
      }
    }
  </function>

To use the function:

targetRoom = FindRoom (5, 1)
msg (targetRoom)

The output:

Object: Tile5


RagnorokX
13 Dec 2017, 02:46

You are AWESOME!
Thanks a lot dude.


K.V.
13 Dec 2017, 02:59

'Twas nada.

The Pixie, mrangel, and HK slapped me around for a month until I learned how to do that.

You are very welcome, though!

Once you're ready to set up objects to clone into the rooms (which would probably be the easiest way to handle nearly everything in the game, once all is said and done), I bet one of the aforementioned notables will pop in with some SUPER-AWESOME scripting (or with links to said scripts).


"The game is on!"
-Watson's sidekick