I was doing the random test when I got the error Invalid expression at char 44, expected no more tokens, found: CLOSE_PARENTHESIS [)]
Here is the code. But I think if I play through the game manually it seems to work fine so just wanted a second opinion to see if there was something wrong with my code or if it’s a weird randomtest glitch.
Thanks.
*selectable_if ((crush = "Daisy") and (daisyfriendship >75)) or ((crush = "Julia") and (juliafriendship >75)) or ((crush = "Emily") and (emilyfriendship >75)) #It went quite well
The parentheses always need to be grouped in pairs, and you have three sets of ((___)) with nothing distinguishing them; they’ll need to be made into a ‘set’ of two as well.
*selectable_if (((crush = "Daisy") and (daisyfriendship >75)) or ((crush = "Julia") and (juliafriendship >75))) or ((crush = "Emily") and (emilyfriendship >75)) #It went quite well
That should work, I think – though there are a few different styles to grouping parentheses that are valid, as long as everything is in pairs.
I find the syntax highlighter really useful to keep track of my parentheses because it highlights which brackets go together when I move through the text with my caret.
Could someone please update the wiki with this? I think this is one of the things giving most people a headdache.
Cause it gets so messy if you wanna do the whole
‘this option should show if EITHER these two variables together, this one variable OR either of these two meet these requirements’ thing (I still can’t wrap my head around how that example would even be coded)
The way I usually try to approach parsing these is by setting out my chain and then adding parentheses in pairs. For your example, I’d jot them down and then work through adding the parentheses like this:
Step 1 *if (A and B) or C or D or E
Step 2 *if ((A) and (B)) or (C) or (D) or (E) (one pair and three stragglers)
Step 3 *if ((A) and (B)) or ((C) or (D)) or (E) (two pairs, one straggler)
Step 4 There are a few ways this final step could go – I might reorder to make it clearer
*if (((C) or (D)) or (E)) or ((A) and (B)) This has all my ‘or’ parts together at the front to make it easier to keep track, and now I have two sets: set (((C) or (D)) or (E)) and set ((A) and (B)): .
*if (((A) and (B)) or ((C) or (D))) or (E) This keeps the original order but still keeps my ‘and’ condition grouped together correctly.
That example looks a little mystifying with all the letters, but if the variable names are clear, the stat check’s logic can be easier to follow:
The guards dash towards you, spears raised.
*choice
#Yell, 'Halt in the name of Their Majesty, ruler of the known world!'
*if (((monarch > 60) and (monarchs_favour)) or ((commanding > 65) or (persuasion > 75))) or (burly > 80)
Astoundingly, they do.
So for the same line I am now getting the error Invalid expression at char 99, expected no more tokens, found: NAMED_OPERATOR [or]
*selectable_if (((crush = "Daisy") and (daisyfriendship > 75)) or ((crush = "Julia") and (juliafriendship > 75)) or ((crush = "Emily") and (emilyfriendship > 75))) #It went quite well
*selectable_if ((crush = "Daisy") and (daisyfriendship > 75) or (crush = "Julia") and (Juliafriendship > 75) or (crush = "Emily") and (Emilyfriendship > 75)) #It went well
The set of three closing parenthesis needs to come after juliafriendship.
*selectable_if (((crush = "Daisy") and (daisyfriendship > 75)) or ((crush = "Julia") and (juliafriendship > 75))) or ((crush = "Emily") and (emilyfriendship > 75)) #It went quite well