+1 vote
by (490 points)
$AlCe[''Already Registered:''
	(if: $Classes's length > 0)[
		(for: each _item, ...$Classes)[_item<br>]]]

$AlCe[''Available Classes'']
(if: all of $Classes is not "Astronomy 1")[
	(link-goto: "Astronomy", "Class: Astronomy")]\
(if: all of $Classes is not "Chemistry 1")[
	(link-goto: "Chemistry", "Class: Chemistry")]\
(if: all of $Classes is not "Coding 1")[
	(link-goto: "Coding", "Class: Coding")]\
(if: all of $Classes is not "Encryption 1")[
	(link-goto: "Encryption", "Class: Encryption")]\
(if: all of $Classes is not "Engineering 1")[
	(link-goto: "Engineering", "Class: Engineering")]\
(if: all of $Classes is not "Firearms 1")[
	(link-goto: "Firearms", "Class: Firearms")]\
(if: all of $Classes is not "Kanyin" and all of it is not "Faemarr" and all of it is not "Nanka'asir" and all of it is not "Psyxene" and all of it is not "Exeltar" and all of it is not "Raonrene")[
	(link-goto: "Languages", "Class: Languages")]\ <-Working. Roughly.
(if: all of $Classes is not "Meteorology ")[
	(link-goto: "Meteorology", "Class: Meteorology")]\
(if: all of $Classes is not "Piloting S1" and all of it is not "Piloting N1")[
	(link-goto: "Piloting", "Class: Piloting")]\ <-Serviceable
(if: all of $Classes is not "Tactics 1")[
	(link-goto: "Tactics", "Class: Tactics")]\
(if: all of $Classes is not "Theology 1")[
	(link-goto: "Theology", "Class: Theology")]\
(if: all of $Classes is not "Triage 0" and all of it is not "Triage 1")[
	(link-goto: "Triage", "Class: Triage")]\ <-Serviceable
(if: all of $Classes is not "Hoverboard" and all of it is not "Ion Surfer" and all of it is not "Hoverbike" and all of it is not "Lunar Glider")[
	(link-goto: "Vehicles", "Class: Vehicles")]\ <-NOT WORKING
(if: all of $Classes is not "Xenobiology 1")[
	(link-goto: "Xenobiology", "Class: Xenobiology")]

(if: $Classes's length is 15)[(goto: "Year 1 Classes Finalized")]

Alright. Most of the above coding is working perfectly. Except that when I try to do something like the following...

(if: all of $Classes is not any of $Languages)[
	(link-goto: "Languages", "Class: Languages")]\
(if: all of $Classes is not any of (a: "Piloting S1", "Piloting N1"))[
	(link-goto: "Piloting", "Class: Piloting")]\

It doesn't work.

 

If it's not clear, I'm trying to make it so that once the player is registered for a class, that class can't be clicked on and accidentally added to the $Classes array twice. I was trying to use the coding in the second set originally, but when it wouldn't make the links go 'poof' after being registered like it was supposed to, I did what I did above.

On the coding at the top, I've noticed that while the Languages coding is working (although I'm highly annoyed at how clunky it looks when I have all six languages stuffed into an array for this exact reason), the Vehicles coding is not, despite being almost identical.

Can anyone explain this, or tell me how to fix it? Any help is always appreciated.

1 Answer

0 votes
by (490 points)
selected by
 
Best answer

Given an array 

(set: $Languages to (a: "Kanyin", "Faemarr", "Nanka'asir", "Psyxene", "Exeltar", "Raonrene"))

and the array

(set: $Classes to (a: "a", "b", "c", "Kanyin"))

To insure that $Classes does not contain any of the values in $Languages, we can do this:

(if: not (any of $Classes is in $Languages))[<!-- Your Code Here -->]

Use the statement

any of $Classes is in $Languages

to figure out if classes contains a value in languages, then use not to invert it.

Test Code:

{
    (set: $Languages to (a: "Kanyin", "Faemarr", "Nanka'asir", "Psyxene", "Exeltar", "Raonrene"))
    (print: $Languages)
    (set: $Classes to (a: "a", "b", "c", "Kanyin"))
    (print: $Classes)
}

(if: not (any of $Classes is in $Languages))[(link-goto: "Languages", "Class: Languages")]

 

by (490 points)
Thank you~ This worked perfectly. I was getting rather frustrated by this.
Welcome to Twine Q&A, where you can ask questions and receive answers from other members of the community.

You can also find hints and information on Twine on the official wiki and the old forums archive.

See a spam question? Flag it instead of downvoting. A question flagged enough times will automatically be hidden while moderators review it.
...