Help with a complex exclusion


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.


Actually, I have an idea for a work-around…

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. :slight_smile: Because learning is always a good thing.


Yeah, I fixed my problem with the workaround. Still curious about it, but it’s not an urgent matter anymore. :slight_smile:


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”))


Thank you. I haven’t tried that yet, but if it is correct, I never would have gotten it right in a bazillion years without help.


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


So, a quick question that ties-in.

What if you have an odd number of conditionals?


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 two pair 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"))


I did mean the smaller examples. Goodness, I hate to even consider things above ten. There’s a point where it becomes
*elseif nope = nope

Those small examples may help me out later in my game, though. Thank you very much. And… you are awesome.


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?

Edit: found it -


@Vendetta I know my version is bad syntax. Does it not work though? I plugged it into the IDE and it seemed to work there.

I was just wondering if there’s a reason I shouldn’t do it that way.


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.