ADRIFT Forum


The place to discuss the ADRIFT Interactive Fiction toolkit

Using "OneOf" with quotes

This forum is the place to learn about and discuss ADRIFT 5. Feel free to mention any bugs you find here, but please also add these to the Bugs & Enhancements list.

Please also refer to the ADRIFT 5 Wiki for more information.

Using "OneOf" with quotes

Postby Lazzah » Thu Apr 23, 2020 3:27 pm

Hi all, I thought that I would share my experience this morning in case it helps anyone.

In my WIP I wanted any one of three messages to be displayed when the PC tries to go south in a certain location. These are:

"Go away," one of the growls at you. "Nobody allowed in here!", "Push off," he warns you. "Move away from this door or we'll make you!" and "That's far enough," one of the guards says menacingly, placing a meaty hand on your chest for emphasis.

I therefore used the "OneOf" expression, trying the following first, with quotes around the speech parts:

<# OneOf(
""Go away," one of the guards growls at you. "Nobody allowed in here!"",
""Push off," he warns you. "Move away from this door or we'll make you!"",
""That's far enough," one of the guards says menacingly, placing a meaty hand on your chest for emphasis.")
#>


With the expression typed like that, on testing the game when I tried to move south I got three error pop-ups when I tried to go south. ADRIFT obviously didn't like the quotes around the speech parts. I then changed the double quotes (") with a single quote (') but that didn't work either.

Not wanting to be defeated I then tried the ultimate solution to this problem - text overrides! In the original expression I deleted all the quotes around the speech parts , so that it looked like this:

<# OneOf(
"Go away, one of the guards growls at you. Nobody allowed in here!",
"Push off, he warns you. Move away from this door or we'll make you!",
"That's far enough, one of the guards says menacingly, placing a meaty hand on your chest for emphasis.")
#>


I then created three text overrides for the three messages, adding the quotes around the speech parts in the Replacement text. On testing the three messages appeared exactly as I intended them to, with quotes around the speech parts.

There may be another solution to this problem which one or more of my fellow Drifters might be aware of but this worked for me and thus I thought I would share it wit you all. It gave me something to use up a bit of time while having to STAY AT HOME during the coronavirus lockdown.

If anyone DOES know of an alternative solution to the above problem, I would be grateful if they would share it with us.
The Axe of Kolt, The Spectre of Castle Coris, The Fortress of Fear, Die Feuerfaust, The Lost Children, Run, Bronwynn, Run, The Call of the Shaman, The Lost Labyrinth of Lazaitch, Magnetic Moon, Starship Quest, Revenge of the Space Pirates
User avatar
Lazzah
Moderator
 
Posts: 2396
Joined: Thu Mar 31, 2011 4:54 am
Location: Clacton-on-Sea, Essex
Points: 65

Re: Using "OneOf" with quotes

Postby Lumin » Thu Apr 23, 2020 3:55 pm

Thanks, this will probably come in handy for me. I'm using OneOf a lot in the main project I'm working on now. Haven't has a bed to try it with dialogue yet but I imagine I would've bumped into this sooner or later and gotten frustrated.

I suppose using alternate descriptions and a random variable is a decent workaround to, but that would get excessively clicky if used a bunch.
User avatar
Lumin
 
Posts: 2152
Joined: Fri Aug 06, 2004 5:48 pm
Points: 49

Re: Using "OneOf" with quotes

Postby DazaKiwi » Thu Apr 23, 2020 9:26 pm

There are two methods to do it

Method 1: "<#oneOf("I wouldn't go into the cave if i were you","You'd be foolish to go into the cave right now","That cave is full of trolls, you would be mad to go in there")#>!"

Method 2: <#oneOf("&quot;I wouldn't go into the cave if i were you&quot;","&quot;You'd be foolish to go into the cave right now&quot;","&quot;That cave is full of trolls, you would be mad to go in there!&quot;")#>

&quot; is built into Adrift to display a " there a couple of others like it, such as &perc; for % and &gt; for > and &lt; for <
I have these saved in a text file ready to copy and paste when i need it, you could also create a template for either method and paste that into a txt file to speed up adding them to your game, and just have to alter the text.

I notice on the forum here because of the font the (and) character looks a bit weird so you have the AND character before the quot;

Also another note if you use method one and some of your speech lines end with a ! and you have a . after the oneOf expression itself it can look odd eg. !. So instead you can just have a full stop after every line of text or ! rather than at the very end like in the example. Hope that makes sense.
User avatar
DazaKiwi
 
Posts: 757
Joined: Thu Oct 21, 2010 9:05 am
Location: New Zealand
Points: 61

Re: Using "OneOf" with quotes

Postby Lazzah » Sun Apr 26, 2020 6:41 am

DazaKiwi wrote:There are two methods to do it

Method 1: "<#oneOf("I wouldn't go into the cave if i were you","You'd be foolish to go into the cave right now","That cave is full of trolls, you would be mad to go in there")#>!"


Method one didn't work with the messages as I wanted them.

DazaKiwi wrote:Method 2: <#oneOf("&quot;I wouldn't go into the cave if i were you&quot;","&quot;You'd be foolish to go into the cave right now&quot;","&quot;That cave is full of trolls, you would be mad to go in there!&quot;")#>


Method 2, using &quot;, worked perfectly - please note Lumin!

:Thanks: :claps: :bravo: :D
The Axe of Kolt, The Spectre of Castle Coris, The Fortress of Fear, Die Feuerfaust, The Lost Children, Run, Bronwynn, Run, The Call of the Shaman, The Lost Labyrinth of Lazaitch, Magnetic Moon, Starship Quest, Revenge of the Space Pirates
User avatar
Lazzah
Moderator
 
Posts: 2396
Joined: Thu Mar 31, 2011 4:54 am
Location: Clacton-on-Sea, Essex
Points: 65


Return to ADRIFT 5.0

Who is online

Users browsing this forum: No registered users and 19 guests