With regards to undefined variables the conditional block isn't skipped at all when dealing with them. If you use the IF/ELSEIF/ELSE statement I posted it shows that undefined is evaluated as FALSE.
Well... there is a small syntax error in your example
it should be
Code:
{if HaveItem=True}True{elseif HaveItem=False}False{else}Undefined{endif}
instead of
Code:
{if HaveItem=True}True{else if HaveItem=False}False{else}Undefined{endif}
So the chapter skips on undefined boolean as well as on undefined variables of the other types. (Though I could imagine adding another option to check against undefined)
Instead of having the 4 options T/U F/U T/D F/D, it could be simpler to have one other button, "default" which is either Show or Hide, and would apply if the condition failed for any reason, including the variable being undefined.
Would be kind of the same as having 4 buttons as you would have 4 options as well.
Then, these options should be available for all variable types as the other types fail the conditions as well when they are undefined.
Having to put IFNOTSET... in the previous chapter is ugly and worse than just defining them all at the start of the story.
E.g. I've now got a handy/logical reference point to check for the correct spelling/capitalisation of my variables.
For a story in development, you will sooner or later reach a point where you have to introduce a variable afterward. So I think that would be a quite handy solution instead of forcing the reader to start over when using a version system or - even worse - let them being stuck at some point of the story.
Basically I was saying although I wish I could handle undefined within the conditions, the way it is currently which forces us to define them up front isn't without merit.
From my current point of view, I would avoid making the conditions any more complex but rather find ways to precalculate such conditions in the parent chapter.
Though we'll see what Friedman comes up with for the next version.
As an alternative to any changes, how about this behaviour is at least mentioned in the Chyoa conditional branches guide?
I added
If a variable used in a Condition isn't present in the reader's score, the chapter isn't accessible.
to 7. Conditions of
Conditional Branches.
and
- if a variable isn't present in the reader's score, the statement will fail
to 9. miscellaneous of
Conditional Branches - If-Statements
Do you think that is that sufficient?
Maybe you want to put your workaround of determining if a variable is undefined within a chapter into the Conditional Branches Showcase (
Examples and
Source Code)
Perhaps in Chyoa3.0 some kind of variables panel could be available for authors that shows all variables used in the story to help with correct spelling/caps, and could let you define defaults as well.
The only way to do that would be to show all variables of all chapters of the whole story, no matter if it is in a parent chapter, child chapter, or another branch.
You mean defaults if the variable doesn't exist?
If we did have a separate variables panel it'd be nice if you could directly edit them as well, so (as author) you didn't have to 'read' through the story to be able to test conditions etc.
You mean a "sandbox" to test the Conditional Branches If-Statements?
Reading through the story shouldn't be necessary as it will become pretty lengthy as soon as you reach a decent chapter depth. To test things deep in the story, I'd recommend creating an unpublished child chapter where you create a set of variables which you want to test, then link directly to the chapter you want to test.
Also, how do you quote in this forum? I don't see any quote links or bb code to do it.
Highlight the text you want to quote and click on the Reply link which appears.
Full quote is also possible with the Reply button at the bottom right of a post.
That doesn't work for quotes in quote, though you can do it manually.
Code:
[QUOTE="dirtytyke"]quoted text[/QUOTE]
[QUOTE]quoted text[/QUOTE]
You could also use the BB Code editor (icon on top right of the editor window)