Howdy, Stranger!

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

Bare Boolean values in the text (Twine 2.0)

edited June 2015 in Chit-Chat
After lots of trial and error, I just realized that while I could put a bare numerical value in the text, a Boolean does not seem to get rendered the same way. Instead of showing "true" or "false," it seems to show up blank.

Is this a bug I wonder or is this part of the way variables are normally interpreted? I was trying to use bare variables to test a Boolean, thinking it was never being defined, but then realized it was defined and just not displayed.

Comments

  • Well... if you have some sample code, I would be willing to check it out for you. Maybe also tell me which format you want me to test in.
  • You may want to use a print statement, or just write the variable name at the end of the passage. It will show the value.
  • Thanks for the print tip. Here is what I was wondering about -- let's say you have this code (in Harlowe)
    (set:$isBillGatesRich to true)
    (set:$money to 5000)
    (set:$string = "Bill Gates")
    
    $undefinedVariable
    $isBillGatesRich
    $money
    $string
    
    (print:$undefinedVariable)
    (print:$isBillGatesRich)
    (print:$money)
    (print:$string)
    

    Outputs:
    0
    
    5000
    Bill Gates
    
    0
    true
    5000
    Bill Gates
    

    What confused me, at first, was that the true/false variable is the only one that comes up blank when dropped alone into the text like this. I wonder what it is about Booleans that get treated differently. I was thinking it would show up as a 1 or 0, at least.
  • edited June 2015
    Set it to false... and literally it does the same thing. You're right. That does seem odd.
  • Just a little something i've asked myself while reading, do you really need it to be a Boolean?

    I mean if it's only to have the output "true or false", why not make it a string by putting quotes on each sides?
  • It is a good question. But as far as printing the words "true": I was only doing it for testing purposes, before writing an (if:) statement that turns on whether the Boolean is true.
  • It could be due to the fact that Harlowe lets you use a bare boolean value to control the printing of an anomynous hook.

    The following two lines will both do the same thing.
    (if: $isbillgatesrich)[yes, so very rich]
    
    $isbillgatesrich[yes, so very rich]
    
Sign In or Register to comment.