Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Better implementation of click: and replace:

edited November 2015 in Help! with 2.0
Hello,

I am writing a story using Twine 2.0.10 / Harlowe where users have the ability to enter a character name and select the character's gender.
I need to store the gender they selected for later use in the story: since the story is written in Italian, which is not a gender neutral language, I need the story to correctly display adjectives and other gendered words related to the character.
(Example: dead is either morta (f) or morto (m). So if I wanted the game to tell the player that their character is dead, the string would chage based on the previous selection).
I don't want, however, to force the user to go through one zillion screens selecting stuff before they can get to the actual story.

My solution so far is the following:

1) A passage that displays a summary of selections on top, and the name selection passage at the bottom:

First passage:
<b>Identità</b>

<hr>
* Nome: []<fname|
* Sesso: []<fsex|
[]<next|
<hr>

(display: "Nome")

Passage named "Nome":
[<b>Nome:</b>
<input type="text" name="fname" value="Jane Doe"><button type="submit" onclick="customScripts.submitName('fname')">OK</button>
(live:100ms)[(set: $yourName = ?fname)]

[Continua]<next1|]<Nome|

(click: ?next1)[(replace: ?Nome)[(display: "Sesso")]]

2) As you can see, once users have confirmed their name, the top of the first passage updates with the name, while the bottom switches to the passage named "Sesso":
[<b>Sesso</b>
[Maschio]<fmaschio|
[Femmina]<ffemmina|
{(click: ?fmaschio)[(set: $x to "o")(replace: ?fsex)[Maschio]]
(click: ?ffemmina)[(set: $x to "a")(replace: ?fsex)[Femmina]]}
[Continua]<next2|]<sesso|
(click: ?next2)[ (replace: ?sesso)[Ti chiami $yourName, il tuo personaggio è (if: $x is "a")[(print: "donna.")] (else:)[(print: "uomo.")]
Ora prosegui con la scelta della classe. Questo servirà a determinare le tue abilità iniziali e l'equipaggiamento.
<div align="center">[[CONTINUA|Classe]]</div>]]

3) Once the gender is also confirmed, the the top of the start passage updates again, and users are sent to the next screen.

This is causing all sorts of compatibility issues as on laptops, where the click / replace link keeps "flickering". (Not sure how to explain this properly, but if you hover your mouse on the link, it keeps quickly cycling between the mousover color and the basic link color. On mobile the issue is even worse as it is very difficult to convice the browser that you have made your selection, and 90% of the times you end up clicking, but nothing happens.

My question is, is there a better way to implement this flow without forcing users to go through three different pages to pick name and gender?

Thank you.

Comments

  • I believe your issue is caused by the (live:100ms) macro, which is interrupting the reader's ability to interact with the screen 10 times a second and will keep doing so until either the reader navigates to another passage or you manually stop the (live:) macro using a (stop:). This could result in the mouse over effect you are seeing.

    The (stop:) needs to be called within the (live:) macro's associated hook, one way to control when the (stop:) is called is to use a variable.

    a. In Nome change the line with the (live: 100ms) macro to something like the following:
    (set: $stopLive to false)
    (live:100ms)[(set: $yourName = ?fname)(if: $stopLive)[(stop:)]]
    

    b. In Nome change the line with the (click: ?next1) macro to something like the following:
    (click: ?next1)[(set: $stopLive to true)(replace: ?Nome)[(display: "Sesso")]]
    

    warning: The above examples have not been tested.
  • edited November 2015
    You are star! :)

    So this fixed the second link (the one in the "Sesso" page), but the one in the "Nome" page is still flickering.
    I think I have what I need to tinker a bit and fix the other one too, so I won't bother you anymore.

    EDIT: for the posterity, in addition to making the chages sugested by @greyelf , I went for the lazy fix of changing the live: value to a slower refresh.
    It seems to be working so far as the game remembers the name chosen by the user and the link does not "flicker" - or rather it does slowly enough that users can move to the next passage.
Sign In or Register to comment.