Copy and Paste in ChoiceScript

Hey everyone. I’m developing a game using choicescript and I’m having a strange problem. I wrote my game in Word, so I could check spelling and grammar, and I assumed that I could copy and paste it into the appropriate textedit document when I was ready to format it for choicescript. But when I try to do this and attempt to run the game, I get an error message, usually telling me that I have a bad label. When I go back into textedit and type in the same information rather than copying and pasting, it works without any problems.

This is the first time I’ve ever tried using a coding language such as this, so all I know is what I’ve learned from this site.^^ Is copying and pasting just not compatible with choicescript? Do I need to type everything in textedit from the very start for it to work? If so, I’m going to have a lot of work ahead of me…I’ve already got 100+ pages in Word.^^;

Any help would be appreciated!

@Shssay It is a problem, for all the reasons you’ve discovered, and unfortunately there’s no easy answer I’ve ever come across. Such as Word and CS just don’t go well together.

The best answer I’ve come up with is to use a text editor with at least a spellchecking function (my personal preference is Textpad) and to which I can add my own words to a user dictionary. All the CS commands are now in my user dictionary, so are simply ignored by the spellchecker, which does at least help reduce the tedium of spellchecking.

That said, it’s also entirely possible that at least some of your bad label errors are precisely that . . . Common mistakes are UpperCase letters in commands or the actual label names, or sometimes spaces:

*Label Jump Here

is not valid, whereas the following are fine:

*label jumphere
*label jump_here

100+ pages? eek! I don’t envy you that task . . .

Edit: belated thought–if your 100+ pages are not all in a single CS scene file, it’s also possible that you have some *goto commands referencing labels (much later in your text) which are no longer now in the same file, which would also result in the bad label error.

Best practice is to download a program specifically intended for coding, such as notepad++.

You can get a spell-checker plugin, I believe.

@CJW I don’t know about anyone else, but I couldn’t get notepad++'s spellchecker plugin to work (but then I didn’t try very hard). Personally I’ve been copying what I do from notepad++ to Word, running the spell checker there, and then making the corrections in notepad++. It’s unweildy, but it works for me.

@Shssay Perhaps you could put what you have in a Dropbox so we can take a look at the errors? It’s hard to give advice without knowing the exact problem. As V said it may just be a few typos. The errors should give you a line number which, if you’re using notepad++ (or any other decent text editor), you can check to see where the error is that way.

Thanks for the help everyone!^^ This newbie really appreciates it.

@Vendetta Thanks for letting me know about the copy and paste. I’m not looking forward to re-typing everything, but at least I won’t waste any more time typing the rest of my story into Word.^^ I was careful about avoiding spaces and capitals in the labels, so I don’t think it’s that. I also have my scenes divided between different word files… So I was really getting baffled about what was going wrong.

@CJW That’s what I’ll do in the future. I don’t think they make notepad++ for Macs, but I’ve read that TextWrangler is a good alternative.

@Reaperoa Sure, here’s a link to the scene I’m working on: https://dl.dropbox.com/u/98762006/ajix_lesson.rtf

@Shssay, I looked at your file. I work on Windows instead of Mac, so some of this might not be the same for you, but I’ll tell you what I found.

First, if you save your file as a text file from Word, you might be able to use it that way instead of doing the copy and paste. I did “Save As” to a text file, and the scene didn’t complain about any labels.

The problems that I did see were two-fold. The first problem is that Word “corrected” your quotes to be print-style quotes instead of normal single and double quotes. So they don’t look like quotes anymore after you save the file as text. You can probably do a replace-all function to replace the “corrected” quotes with normal quotes. You’ll have to replace all of the “right hand” and “left hand” quotes with normal quotes. I hope you understand what I’m talking about.

Another problem I see is when you use an *if to check a boolean value. For instance, I see this command in your file:

*if fightwithajix true

You need to insert an equals sign between the variable and the value you’re checking against, so it should look like this:

*if fightwithajix = true

I saw a couple of places where that kind of error occurred.

Otherwise, as long as you have all of your variables defined in mygame.js, you should be fine after dealing with the above issues. I noted the following variables that needed to be defined in your mygame.js file (I include the sample values I used for testing purposes):

cat_name: “cat name”
,character_name: “character name”
,gender: “gender”
,charm: 50
,ajix_affection: 50
,perception: 50
,intelligence: 50
,allergic_to_cat: false
,cat_affection: 50
,fight_with_ajix: true
,fightwithajix: true
,taran_affection: 50

There might be others that were used in paths I didn’t take when testing the scene.

I also tried copy and paste of your text into a scene file, and it worked the same as saving as text. So, as mentioned before, there might be some difference between how Windows works and how the Mac works in this regard. One thing you might want to check is whether the long lines are preserved when you do the paste. If your copy/paste operation breaks your long lines and makes short lines out of them, then that will throw off your indentation and will definitely cause problems of who knows what sort.

Hope some of what I’ve said is of help. Good luck!

@eposic Thank you so much! When I did what you told me, it fixed my problem.

Thanks to everyone for taking the time to help me out with this.^^

@Shssay, glad to hear it!

Hey everyone, I’m having another problem I’m hoping someone can help me with. I keep getting an error that says “expected option starting with #”. I’ve tried to fix it a few different ways, but the error keeps occurring. Here’s the section of text that’s giving me the error:

*label weapon_practice

You make a few test swings with your new weapon, checking its weight and balance.  In addition to the ${character_weapon}, you select a flintlock revolver for yourself as well, unable to resist the possibility of a little target practice with these cutting-edge firearms.

Up until this point, the pistols used by your army’s soldiers were fashioned with several barrels attached to them to provide more than a single shot, but they were…problematic.  According to reports from the battlefront, these guns were prone to exploding in a soldier’s hand rather than firing correctly.  King Torquil’s engineers have promised that these self-priming models were not only supposed to fix this problem; the spinning cylinder would also provide a soldier with six shots before having to reload, even though the gun was only built with a single barrel.  Hopefully the weapon functions as promised.

"A ${character_weapon} huh?  Interesting choice."  Taran says from behind you.  "Shall we spar for a while, or do you want to try out that new flintlock?"
*choice
	#"I'm eager to test out this flintlock revolver.  Let's do some target practice."
		Taran seems a little disappointed but he nods, reaching for one of the revolvers.  "Okay, but I'm not a very good shot.  Not to mention I'm not so sure that King Torquil's engineers have worked out all the kinks in these things…  I don't know about you, but I'm fond of my fingers."
		*goto test_fire
	#"I want to try out this ${character_weapon}."
		"Sounds good."  Taran grins, stretching his broad shoulders and cracking his knuckles before selecting a sword from the weapon racks.  "Let's get started."
		*goto sparring_with_taran

The first option works, but the second keeps giving me an error message. Any ideas on what I’m doing wrong?

Hmm, I can’t remember the last time I saw that error (or what caused it) but at a guess I would say it sounds like you have a line of text indented to the same column as your current #options but is not actually intended to be an option, which is why it has no # preceding it.

Bear in mind that your text may look fine (i.e. correctly indented) at a glance but not in the way CS looks at it. For example, extra spaces / tabs at the end of a particular line can in some circumstances be interpreted by CS as being the start of the next line. Granted, this usually results in actual indentation errors, not the problem you have here, but it’s the first thing I’d look into, for want of a better idea.

e.g. If you have an extra space / tab at the end of *goto test_fire it might be pushing the next option over (as CS reads these things), putting it out of alignment despite appearances.

Some text editors have a “View Visible Spaces” option, which when turned on will mark each space and tab with a tiny symbol. That can be a big help in finding extra indents where they’re not supposed to be / can cause problems (e.g. after a *choice command).

Correction to the above (although it still applies in terms of general advice for avoiding / dealing with indentation errors!) . . .

You’ll find the error starts on the following line:

“You need to mind your stance, my . . .”

which is line 80 in the file choose_your_weapon.txt, not where you think it is.

Basically, that paragraph and the few following ones (down to the line *goto speaking_with_torquil) all need indenting one more step. As I originally suspected, they’re in alignment with the #options above, so CS thinks this is the start of another #option, minus the necessary # symbol.

One other bit of useful advice for future reference–pay particular attention to the last line of visible text when an error occurs. This usually means it was fine up to (and including) that point, and did not error until immediately after.

Thanks a lot! That fixed the problem I was having with it. And thanks for taking the time to give me tips on using choicescript. I’ve learned quite a bit from this thread and I’m sure it’ll help me avoid future errors.^^

Teething problems, is all . . . we’ve all been there (well, we non-programmers, anyway)!

Those 100+ pages were time well spent as it’s shaping up to be a great story, very well written (that tutor reminded me so much of my old history professor it made me chuckle) so I’m glad you persevered with the scripting side of things. I’m looking forward to seeing more of this one.

I’m glad you liked it!^^