Erasing a specific letter

MsXler
To be more exactly, I want to integrate a mechanic in my game that should cause confusion to the players by editing already written text in the currently running game. Do you know of any method to manage that?

I'm thankful for every answer.

The Pixie
I would override the OutputText function to replace the given letter with an HTML span with a certain class. You should then be able to use JavaScript/CSS to either set it to be not visible or set it to the same colour as the background when you want to hide it.

Take a look at the OP on this thread, and in particular the function that changes the letter A (it just does that for room descriptions, you need to do this with OutputText to change all text):
viewtopic.php?f=18&t=5058

Is that enough to get you started?

Silver
I would (quite predictably) use a flag. Then you can just use the text processor to make alterations. If this is a game-wide thing though it might be too much of a headache. Say you want to delete the letter n. You could create an attribute in the startscript like:

game.lettern = true


Then you could print a message somewhere like this:
msg ("There is {if game.lettern:n}othing that {if game.lettern:n}arks me more than a{if game.lettern:nn}oying scripts.")


If game.lettern = true it would read:
There is nothing that narks me me more than annoying scripts.
If game.lettern = false it would read:
There is othing that arks me more than aoying scripts.

jaynabonne
That won't change text that's already been printed though. Once it goes through the text processor, it just becomes text (no longer bound to the variable).

Silver
On second read I see what you mean. I'm confused by the question now though.

The Pixie
Here is a quick example game. Type WHITE to make the letter "a" disappear, and BLACK to make it reappear.
<!--Saved by Quest 5.6.5508.33899-->
<asl version="550">
<include ref="English.aslx" />
<include ref="Core.aslx" />
<game name="Disappearing Letters">
<gameid>ca3312b9-336c-4b9d-a76d-45d2c8896188</gameid>
<version>1.0</version>
<firstpublished>2015</firstpublished>
</game>
<object name="room">
<inherit name="editor_room" />
<alias>Bedroom</alias>
<description>A large room, dominated by a four-poster bed. A bay window overlooks the grounds.</description>
<object name="player">
<inherit name="editor_object" />
<inherit name="editor_player" />
</object>
<exit alias="south" to="drawing_room">
<inherit name="southdirection" />
</exit>
</object>
<object name="drawing_room">
<inherit name="editor_room" />
<description>The drawing room looks very elegant, the wall panelled in dark wood to match the chairs.</description>
<exit alias="north" to="room">
<inherit name="northdirection" />
</exit>
</object>
<command name="white">
<pattern>white</pattern>
<script>
JS.eval ("$('.lettera').css('color', 'white');")
</script>
</command>
<command name="black">
<pattern>black</pattern>
<script>
JS.eval ("$('.lettera').css('color', 'black');")
</script>
</command>
<function name="OutputText" parameters="text"><![CDATA[
data = NewDictionary()
dictionary add (data, "fulltext", text)
text = ProcessTextSection(text, data)
s = ""
in_tag = false
for (i, 1, LengthOf(text)) {
c = Mid(text, i, 1)
if (c = "<") {
in_tag = true
s = s + "<"
}
else if (c = ">") {
in_tag = false
s = s + ">"
}
else if (c = "a" and not in_tag) {
s = s + "<span class=\"lettera\">a</span>"
}
else if (c = "A" and not in_tag) {
s = s + "<span class=\"lettera\">A</span>"
}
else {
s = s + c
}
}
OutputTextRaw (s)
]]></function>
</asl>

For those interestyed in the details, for the JQuery and CSS, I use:
 JS.eval ("$('.lettera').css('color', 'white');")

Usually we use a # before the idfentifier, but in the case I am changing a class of elements - the difference being you can have more than one element with the same class. Every letter "a" is of the class "lettera", so I used .lettera rather than #lettera.

To get the letters to disappear altogether you can use this instead:
  JS.eval ("$('.lettera').css('display', 'none');")

And to get them back:
  JS.eval ("$('.lettera').css('display', 'inline');")


Overriding OutputText turned out tobe more complicated than I was expecting because the text has "a"s in some HTML tags, and they were getting replaced too. I had to go throughthe string a character at a time and only change letter "a"s that were not in tags. This means you cannot use "<" or ">" in your text (except for HTML).

MsXler
@ Silver: Your solution is actually wonderfully applicable. The only backdraw is, I would have going to have a bad time reading the bracketified messages, though.
@ The Pixie: Your hiding solution rather than your coloring solution would make more sense in my problem, as with latter, the player could select whited-out letters and therefore be able to read them again. But as far as I understand, your script does control every printed a, so I could really need a way to define an influence region (which also must be able to lie farther behind in the game's protocol), in which the a-manipulation is also independent from the a-manipulation from the other influence regions.

I thank all three of you for your responses! For now, I will experiment with your approaches a little bit, and see if I might actually figure out the solution myself.

This topic is now closed. Topics are closed after 60 days of inactivity.

Support

Forums