I’m trying to set up naming in my game, but the guide on the wiki :
Isn’t helping. I keep getting an Operator error “expecting OPERATOR, was OPEN_PARENTHESIS[(]”
I don’t want it as “first name” “last name”, but “first name” “val” “last name”. Can anyone help me figure out how to set it up?
If you’re just trying to print that, then assuming firstname and lastname are already created and assigned the right values,
${firstname} val ${lastname}
will work.
*create firstname “Unknown”
*create lastname “Unknown”
*create fullname “Unknown val Unknown”
*set fullname ({firstname} val {lastname})
Gets me
startup line 27: Invalid expression, couldn’t extract another token: {firstname} val {lastname})
Try this:
*set fullname (firstname&" val ")&lastname
this should help.
@P_Tigras the point of concatenating in so that you don’t have to keep writing that 3-variable name over and over, it’s much easier to just write one variable.
You might need to copy the example in the Concatenation section a little more closely if you want it to be helpful…
*create firstname "Unknown"
*create lastname "Unknown"
*create fullname "Really Awfully Unknown"
*set fullname (firstname&" val ")&lastname
My name is ${fullname}.
Try running it in CSIDE to confirm that it works.
Edit: NinjaLamia!
1 Like
That worked, thank you all for your help.
I understand the point of concatenation. I simply failed to make the very tiny leap of logic from the name of the link that concatenation was what he desired since he didn’t specify it in his post outside of the link itself. It’s 3am here and I’m tired…
1 Like
I just don’t think I’m understanding concatenation.
*set appearance ((hair&","&eyes)&(skin))
*set appearance ((hair&",")&eyes",")&skin
and other variants all come back with an operator error
you have to be careful of where you use the brackets, and where not to use them.
using concatenation, groups them into groups of two. you can only concatenate 2 parts at a time
hair&", " being the first group, bracket them. This makes them one part. after this,
(hair&", ")&eyes now this means that there are still 2 "parts" there, because the brackets cause hair and the comma to form into 1 part.
(hair&", ")&(eyes&", ") now, hair and first comma are part 1, with eyes and second comma being part 2
((hair&", ")&(eyes&", "))&skin this should make everything in the brackets part 1, while skin is now part 2.
Haven’t tested it, but this should work now.
4 Likes
Gavorn
June 5, 2016, 1:20pm
10
That worked, thank you so much. I don’t think I’d ever have figured out how it grouped them on my own.
1 Like
lexa
June 5, 2016, 1:24pm
11
Totally unrelated but I read Help with nanning instead of Help with naming and laughed so much anyway I’ll see myself out.
Terrific explanation. Worth noting that the “only 2 things at a time” rule applies to many things in ChoiceScript:
The key thing with logic statements like “or” and “and” is to give CS no more than 2 things to deal with at a time.
Anything in parentheses counts as one thing. So if you’ve got three things, tuck two of them in an extra parenthesis to turn them into one thing. That’s what I’ve done in the example above , turning two things
(var1 = 1) or (var2 = 1)
into one
((var1 = 1) or (var2 = 1))
If you wanted to take a fourth variable into account, just plop everything you’ve got so far inside another p…
2 Likes