Hey!
I’m working on a character creation system in Twine 2.0 and have run into a problem with whitespace. At the moment the *buttons* work the way I want them to, however the code seems to be very clunky and not only does it produce an error but it produces an ever expanding amount of whitespace below the buttons every time they are clicked. I’ve tried using { } to place all the code onto a single line but this doesn't seem to work. Although it does place all the code onto a single line, when the buttons are pressed it seems to create new code. I assumed it was something to do with the link repeat macro but I tested that on its own and it doesn't produce whitespace when clicked. (Just to clarify I know the error is an issue but the whitespace appearing was a problem before I introduced that part)
Can anyone recommend a potential solution to this? The increasing amount of whitespace makes it impossible to write anything under the *buttons*.
Thanks!
(set: $Health to 5)
(set: $Attripoints to 5)
(set: $Apointsplus to true)
Attribute Points = [$Attripoints]<attripoints|
{Health = [$Health]<health| (link-repeat: "Health +1")[
(if: $Attripoints >= 1)[(set: $Apointsplus to true)]
(if: $Attripoints <= 8)and(if: $Apointsplus is true)[
(set: $Health to $Health +1)
(set: $Attripoints to $Attripoints -1)
(replace: ?health)[$Health]
(replace: ?attripoints)[$Attripoints]
(if: $Attripoints is 0)[(set: $Apointsplus to false)]]]
(link-repeat: "Health -1")[
(if: $Attripoints < 8)[
(set: $Health to $Health -1)
(set: $Attripoints to $Attripoints +1)
(replace: ?health)[$Health]
(replace: ?attripoints)[$Attripoints]]]}
Comments
This causes the page to grow structurally in length which may be visually noticeable if the contents of the associated hook contains any Text output including line-breaks, which is the case with your example.
(This effect can be see if you look at the story HTML page using your web-browser's Development Tools.)
note: Your example includes a syntax error, the and between the second and third (if:) macros, and those macros themselves should be merged to create a single (if:) macro.
The following is a corrected version of your example with extra White-space Collapsing added, I also reformatted it so it was more readable which you can safely remove.