Also, hot on the heels of my previous question: is there a way to put a new line before or after the take message / drop message (I can't do it in the GUI and I don't know how to code it)? I have quite a few messages popping up at various places in my game and I'm having a bit of a nightmare making everything format nicely with proper line breaks (I've set the various newline options in the Room Descriptions tab in the game object, but there is still tweaking required to prevent either lack of line breaks or too many line breaks).
I can't check at the moment, but... try putting
<br> at the end of the line. It creates a line break.
Thanks - but that doesn't work. It gives an error about nested XML when the game is compiling.
BUT (incredibly) I managed to figure this out myself, by overriding the DoTake function and adding the line break there:
msg (prefix + takemsg+"<br>")
With this, what would be handy, I think, is an option for adding a line break after every output. At the moment I'm adding line breaks to message here and there to make it output nicely, (eg turnscript messages not clumping together with an object description without a line break etc), but it's not a very efficient way of doing it. That's just me being fussy about typesetting, and may be there is something obvious that I'm overlooking, but there it is.
(eg turnscript messages not clumping together with an object description without a line break etc)
I think the most obvious way to do that would be to put a line break before the turnscript.
You could even make a turnscript (named something like
00linebreak to make it sort before other turnscripts) which outputs a line break only if the output doesn't currently end with a blank line:
JS.eval("var b = getCurrentDiv().find('div span').last();b.text() && !b.contents().last().is('br,hr').length && addText('<div><span><br/></span></div>');")
(off the top of my head; might have an error there, but it should account for both a
msg("") and a line ending with
Or depending how many blank lines you're inserting, it might be more efficient to add a CSS block; give every paragraph a
margin-bottom or similar to space out the output.
EDIT: Fixed a careless error, adding
Thanks - the JS runs without errors...have added it and will see if it fixes the issue!
EDIT: Silly mistake; I missed out
Actually, it might be better to do:
JS.eval("var b = getCurrentDiv().find('div span').last();b.text().match(/\\S/) && !b.contents().last().is('br,hr').length && $('<br>').appendTo(b);")
(Everything that you pass to Quest's
msg function gets a
<div><span>Your text here</span></div> wrapper around it, with a large bunch of style information, and is then passed to the JS function
addText. The first version I posted above just made a new
<div><span> block, but without all the style information; so the blank line inserted wouldn't necessarily be the same font size as the rest of the text. This second version should get the text that was added by the last
msg call, and if that line is neither blank nor ends with a
<br>, it adds a
<br/> to the end of it)
I've added it but it doesn't quite fix the problem.
It's this sort of thing that is annoying:
> turn on taps
They are already turned on.
Oil flows into the bath and drains away down the plughole...
...Where the first line is the output from using a verb and the second a turnscript message, and I want a new line between the two. Obviously, I can just go through all the messages and add a break at the end of them when I spot it, but would be easier if there was a way to automatically insert a new line between every separate message / output. But if it can't be done, then I can live with doing it manually!
I can't spot an error in the code; I might have to try putting together a test game later so I can look at the output and see if that gives any clues. Sometimes hard to debug things without being able to see it.