|
Hazram Wanderer
Joined: 24 May 2005 Posts: 71
|
Posted: Wed Oct 05, 2011 5:16 pm
Insert a soft return into a string? |
I'd like to deal with changing descriptions for day/night on my mud by formatting such descriptions in the mapper database thusly:
Quote: |
DAY:This street is quite buys now, in the full light of day.
NIGHT:Even after dark, small clusters of people can be seen walking to and fro. |
To make the needed conversions, I need to be able to insert a soft-return into a string, for the division between DAY and NIGHT portions. This is just a cosmetic step, but without it the stored descriptions are much less readable. I'm not sure how to do this - any tips?
Every other part of the conversions I can handle in such a way that I simply walk my map and the Desc values are updated correctly, so I'd rather not try to do this part by hand - that would be so tedious. |
|
|
|
charneus Wizard
Joined: 19 Jun 2005 Posts: 1876 Location: California
|
Posted: Wed Oct 05, 2011 5:33 pm |
Where are you entering the information? Are you doing it by hand? Are you modifying the room description itself, or are you making a userint string with the information?
If you're doing it as part of a userint string, you can put the pipe ("|") character to separate the two (can just do %additem via script) and then you can expand it with %expandlist using %cr as the modifier.
You can use %cr if you're doing it by hand, as well. |
|
|
|
Rahab Wizard
Joined: 22 Mar 2007 Posts: 2320
|
Posted: Wed Oct 05, 2011 5:38 pm |
It sounds like you are already using #TAG to designate the room description? If not, that's the command to use. As for the soft return, the pre-defined variable %cr designates a carriage return. It can be inserted into a string with %concat(), %insert(), #SUB, etc.
|
|
|
|
Hazram Wanderer
Joined: 24 May 2005 Posts: 71
|
Posted: Wed Oct 05, 2011 5:50 pm |
Yep, I'm using #tag for new rooms and %roomdesc for existing rooms. I'm avoiding using the UserStr field for this, as this field is also useful for me in other ways, and putting a lonnng text string in that field as well would make it rather un-human-readable.
%cr was just the thing I was looking for, though maybe %char(10) would work too? Note to self, check the pre-defined variables list more often.
I bet I can get things working with these. |
|
|
|
Hazram Wanderer
Joined: 24 May 2005 Posts: 71
|
Posted: Wed Oct 05, 2011 6:50 pm |
For completeness, here's an example of my script for the conversion task. The pattern matches any room description, though I won't bother showing or explaining it - it's quite a beast.
the script below tags the modified description for the mapper (in case a new room is being created), then calls %roomdesc to update previously existing rooms. If the room is missing a description, one is added. If the room has a stored description, but it doesn't match the description output by the mud, the currently stored description is assumed to be the nighttime description, and it is updated. Obviously this version is suitable for daytime walking.
Code: |
$myDesc = %concat("DAY:", %1)
$roomDesc = %roomdesc()
#TAG desc $myDesc
#IF ($roomDesc = "") {#CALL %roomdesc(, $myDesc)} {#IF (!%match($roomDesc, %1)) {#CALL %roomdesc(, %concat($myDesc, %crlf, "NIGHT:", $roomDesc))}}
;/Map/desc = %1 // debugging
#T- getDesc trigger // this trigger |
The second #IF test uses %match, when a simple comparison with = would be suitable in this case. %match, however works better with variations of this script, which update with a bit more complexity. |
|
|
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|