Okay, I’ve got one line that’s giving me trouble, and I can’t figure out how to script it properly. This is what I’ve got written for the line:
*elseif (name != “Sam”) and (name != “Chelsea”) and (name != “June”) and (name != “Ashley”) and (name != “Adam”) and (name != “David”) and (name != “Josh”) and (name != “Mike”)
In essence, I want an *elseif that excludes those MC names. The error I’m getting is:
startup line 817: Invalid expression at char 43, expected no more tokens, found: BOOLEAN_OPERATOR [and]
That’s the line indicated, above. I’ve also tried not using (name != except at the beginning of the line- that doesn’t help. Can anyone give me advice on how to fix this? Thank you.
Basically, I want to make this *elseif happen if you’ve entered your own name for your MC.
So what I think I can try, is to create a variable that turns ‘on’ if you enter your own name, and then apply that variable here. smacks self in forehead
Still- it would be cool to hear how to properly code that sort of line. Because learning is always a good thing.
I think you’re lacking in brackets around things. I think it’s something like
*elseif ((((((((name != “Sam”) and (name != “Chelsea”)) and (name != “June”)) and (name != “Ashley”)) and (name != “Adam”)) and (name != “David”)) and (name != “Josh”)) and (name != “Mike”))
When dealing with multiple conditions it’s usually best to stick to the “two pair” rule, which simply involves enclosing each pair of conditions within an extra set of parentheses, and also each pair of pairs as in your case. For instance:
*elseif (((name != "Sam") and (name != "Chelsea")) and ((name != "June") and (name != "Ashley"))) and (((name != "Adam") and (name != "David")) and ((name != "Josh") and (name != "Mike")))
To break this down; this is the first pair enclosed within extra parentheses -
((name != "Sam") and (name != "Chelsea"))
and this is the first pair of pairs enclosed within another set -
(((name != "Sam") and (name != "Chelsea")) and ((name != "June") and (name != "Ashley")))
and the second pair of pairs enclosed within its own set of parentheses -
(((name != "Adam") and (name != "David")) and ((name != "Josh") and (name != "Mike")))
together combined with an ‘and’ in the middle to form the complete statement as one line of conditions, as shown in the first example above.
I… actually understand you. XD Either you did an amazing job explaining that, or I’m getting better at understanding scripting than I’d have thought. laughs
e.g. adding a 9th one to the above? Well, firstly there comes a point when you should be looking for an easier alternative (e.g. the workaround you mentioned earlier…) but often you can just add odd ones on the end as in the following example. However note that in this case because you have twopair of pairs already there, you will need to enclose these in yet another another set of parentheses, as follows -
*elseif ((((name != "Sam") and (name != "Chelsea")) and ((name != "June") and (name != "Ashley"))) and (((name != "Adam") and (name != "David")) and ((name != "Josh") and (name != "Mike")))) and (name != "Vendetta")
Edit for smaller examples… Three conditions -
*elseif ((name != "Sam") and (name != "Chelsea")) and (name != "June")
Five conditions -
*elseif (((name != "Sam") and (name != "Chelsea")) and ((name != "June") and (name != "Ashley"))) and (name != "Adam")
Seven conditions -
*elseif (((name != "Sam") and (name != "Chelsea")) and ((name != "June") and (name != "Ashley"))) and (((name != "Adam") and (name != "David")) and (name
!= "Josh"))
You’re most welcome. I don’t know about “awesome” but on that note there is an excellent thread around here someplace by @Havenstone where all of this (and the use of and / or) is brilliantly explained, but I regret I seem to have mislaid the URL… Perhaps someone could link to it here?
Hmm. Good question. Way back in the days when I used to mess about with spreadsheets the equations used to look very much like what you’ve done there, so I don’t doubt that the basic coding logic is correct (and especially so if it works in the IDE). When I started learning CS, however, the “two pair” approach I’ve outlined above was deemed the correct way to do things for our scripting purposes, so I adapted accordingly just in case CS one day evolved enough to make the “old way” of doing things unworkable. I don’t think we’ve actually reached that stage yet but it’s always a possibility, hence my recommending the “two pair” approach.