Codewords


#1

Greeting to all members. I just finished a gamebook (well, there’s some polishing work to be done, but at least most of the work s done).
One of the mechanics I use most heavily is codewords. So far, I haven’t seen an explanation how to code them, not at least something a programming noob like me could comprehend.

Another question I would like to ask would be if numbers could be used to name labels. I’m under the impression that labelling each section might be the most convenient way to code what I have.

Thank you in advance!


#2

What do you mean by codewords? Can you provide an example?


#3

I’m sure Mayday is meaning commands…

*choice
as such…
*goto_scene 845241

But i’ve never actually given that a try on just number i’m sure it’s possible but may take some variables. And Mayday check out
http://choicescriptdev.wikia.com/wiki/ChoiceScript_Wiki.

Best I can say for figuring out coding. Me being so bad at it =p


#4

I was assuming that Mayday meant codewords as in the solution to puzzles.

Like

You’re standing in front of a locked door.

What is the password.

*choice
#Open Sesame
#Abracadabra
#Open Please
#What?
#Speak Friend and enter.

Hence the need for clarification.


#5

If you mean to use codewords with the *input_text command, you’ll just need a ‘holder’’ variable and what it is supposed to equal.

Let’s assume the ‘holder’ variable you use will be codeword, and the password is ‘redrum’

Simply run:


What is the password?
*input_text codeword
*if codeword = "redrum"
  You're correct.
  *goto correct_answer_given_to_puzzle
*else
  You're wrong.
  *goto a_bolder_crushes_you_because_you_didnt_get_the_password

Now, something to keep in mind “redrum” != “Redrum” != “Red Rum” != “Red rum” (and so on and so forth), so in the above case, if someone answered “Redrum”, they’d be wrong. Make sure to either clarify, or to include every reasonable possibility of capitalization.

As for the label questions, yes, labels are alphanumeric. I’m not sure if purely numeric labels would work correctly, but I’d recommend against it anyways.


#6

I’m really sorry for the lack of clarity. Codeword is something the reader writes in their adventure sheet so that their actions have future results.

For example, if you meet the big gray wolf and give him a piece of pie, you are instructed to write down codeword PIE. Next time you meet the wolf, you are asked if you have cideword PIE. If you do, he might be willing to help you fight the evil hunter.

I hope now it’s clear :). Thanks for your answers anyway.


#7

I suppose you could do that, but variables essentially do the same thing, without forcing readers to remember said codeword. If you prefer it that way, sure, whatever.


#8

I was thinking the same thing - just set all 10 (in my case) codewords as Bullean variables (sorry if the spelling is wrong)


#9

One of the big advantages of writing this as an online novel rather than on paper is that the “codewords” can all work behind the scenes. It means you don’t have to break people’s suspension of disbelief by asking them to (for example) type in PIE in order to fight the hunter – the story will just smoothly flow one way or another, depending on what you chose back in the wolf-feeding scene.

There can still be enjoyable challenges where the character has to give a password, in which case @Reaperoa’s code above is just what the doctor ordered. There, the codeword is part of the story, not an interruption to it.


#10

Reaperoa is very right, that’s how it’s done and this method is very useful. I have used this system in my game (which I am thinking of leaving it) as a password system. You just use an input command, check with an *if, to see if it matches the code word, and walla! You have a codeword system. Here’s an example from my code as well.

*label begin
*fake_choice
	#Begin the Game
		*finish [b]Begin [i]Life in Ancient Greece[/i][/b]
	#Skip to Chapter (Password Required)
		Which Chapter to you want to skip to?
		*choice
			#Part II : The City
				Password? (First Letter as Capital will be accepted)
				*input_text password_city
				*if (password_city = "snake") or (password_city = "Snake")
					*goto_scene city
				*else
					*goto password_wrong

*label password_wrong
Sorry, Wrong Password.
*goto begin

#11

@Reaperoa
Purely numerical labels will work just fine. Labels are strings, so numbers or letters, they’re all treated exactly the same. But yeah, it’s probably not a great idea - unless you’re using some pattern math with *gotoref.


#12

Oh for that you can just do


*choice
    #Give the wolf the pie
        *set pie wolf
    #Eat the pie in front of the wolf
        *set pie eat

And then later on


You see a wolf

*if pie="wolf"
    The wolf remembers you gave him the pie and helps you.
        *goto wolf_help
*else 
    The wolf is starving and eats you.
        *goto dead