Howdy, Stranger!

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

twine2 bug? prompt complains with - _ or . in $

I'm putting together a sample work book built in twine for teachers etc

I get very different behavior, none desirable, with these bits of code:
-------------------
note: dashes do not work with into $
(put: (prompt: "Have you ever sequenced DNA?") into $seq-DNA)

note: underscore do work with into $
(put: (prompt: "Have you ever sequenced DNA?") into $seq_DNA)

note: periods do notw : error: I can't give undefined a new value
(put: (prompt: "Have you ever sequenced DNA?") into $seq.DNA)


What you said first time
$seq-DNA

2nd time
$seq_DNA

3rd time
$seq.DNA
-------------

It prompts me twice but only one prompt answer is captured.

Here is the whole very alpha workbook with lots of notes:

http://pastebin.com/CvR57cX3

thank you for your time.


Comments

  • Each of the different Story Formats haves their own set of features and limitations, from the format of the macros your using I am assuming your using Harlowe.

    I believe that Harlowe has restrictions on which characters are allows within variable names.

    If you gave each of your three examples different prompt texts you would discover that the first prompt shown is from example 2 and the second prompt show is example 3. I will try and explain what is happening in each of your examples:

    1. (put: (prompt: "Have you ever sequenced DNA?") into $seq-DNA)

    No prompt is shown because Harlowe can't determine what DNA represents. I believe it sees $seq-DNA as the variable $seq minus something named DNA.
    So even if it knew what DNA was the value entered into the prompt would more than likely be stored in a variable named $seq.

    2. (put: (prompt: "Have you ever sequenced DNA?") into $seq_DNA)

    This works as expected because Harlowe allows variable names to contain underscores.

    3. (put: (prompt: "Have you ever sequenced DNA?") into $seq.DNA)

    This one is strange because a prompt is shown but it has problems storing the input into a variable.
    In Javascript if you try to reference something that does not exist it equals/returns undefined (a special object), and it appears that the above code is trying to assign a value to undefined which is not allowed hence the error message.

    4. The reason why both $seq-DNA and $seq.DNA appear the way they do is because both statements think you want to print the value of $seq (currently zero) along side some text, "-DNA" in the first case and ".DNA" in the second.
  • [quote author=writer_ link=topic=2300.msg6797#msg6797 date=1422200188]
    note: dashes do not work with into $
    (put: (prompt: "Have you ever sequenced DNA?") into $seq-DNA)This can't really be made possible because - is the minus sign. Do you think this should be allowed?
    [quote author=writer_ link=topic=2300.msg6797#msg6797 date=1422200188]
    note: underscore do work with into $
    (put: (prompt: "Have you ever sequenced DNA?") into $seq_DNA)Underscores are allowed, and always have been, but do you think they maybe should not be allowed?
    [quote author=writer_ link=topic=2300.msg6797#msg6797 date=1422200188]
    note: periods do notw : error: I can't give undefined a new value
    (put: (prompt: "Have you ever sequenced DNA?") into $seq.DNA)Periods don't work, but I guess it would be possible to make them work, albeit at the expense of locking out other Javascript hacks used in some places. Do you think this should be allowed?
Sign In or Register to comment.