Auto description newline

Doctor Agon
05 May 2018, 22:45

Currently in my game, and I suspect most peoples games, on the 'Room Descriptions' tab of the main 'game' object, I've got the following 'Room description layout' options ticked.
Put a new line after the room name - tick
Put a new line after the objects list - tick
Put a new line after the description - tick

When I visit a room in the game that has all these things, it's displayed nice, with only one blank line between sections - Great.
However, when I visit rooms that no objects are currently in, there seems to be too much gap.

eg.

East Side of House

You are standing on a path.




You can go north

I've been looking in the 'ShowRoomDescription' function and been trying to check that if there are no objects in the room, not to print the extra line. It's probably something so simple, but at the moment I'm drawing a blank, can anyone help.
Just for reference, the objects section of the function is as follows.

if (i = game.autodescription_youcansee) {
      objects = FormatObjectList(game.pov.parent.objectslistprefix, GetNonTransparentParent(game.pov.parent), Template("And"), ".")
      desc = AddDescriptionLine(desc, objects)
      if (game.autodescription_youcansee_newline) {
        msg (desc + "<br/>")
        desc = ""
      }
    }

Many thanks


mrangel
05 May 2018, 23:30

Maybe change
if (game.autodescription_youcansee_newline) {
to
if (game.autodescription_youcansee_newline and not (objects = "")) {
?

So it ignores the "Put a new line after the objects list" setting if the "objects list" line is empty.

(I found this whole bunch of code so ugly that I did a complete rewrite of it a while back, making this behaviour more consistent. Can't find it now, though)


hegemonkhan
05 May 2018, 23:47

http://docs.textadventures.co.uk/quest/functions/#scope

if (ListCount (WHATEVER_SCOPE_FUNCTION) = 0) {
  // if no Objects in Room (or what/where else), do/have your desired scripts here, lol
} else {
  // if Objects are in Room (or what/where else), do/have your desired scripts here, lol
}

as for the empty vs non-empty lines issue... you can use 'foreach' and concatenation to manually format how you want your empty vs non-empty lines to look


Doctor Agon
06 May 2018, 04:42

Thanks guys, that worked a treat. Looks so much better.