I’m new. and never done code, ever. I’ve read the online tutorial and performed trial by error but without success on one thing.
In ChoiceScript, I want to offer things a character can pick up based on previous choices they have made, i.e. gun, knife, food, medikit, etc.
They may only get 1 of these. For example, let’s say they find a knife but nothing else. 5 page breaks later, they get a menu of choices that allows them to use what they have found, in this case, only a knife.
I only want 1 option, the knife, to be a selection. “Use the knife to cut the vines”
And, I want the other choices to display but not to be a valid selection.
“Ready my gun while trapped in the vines”
“Eat food while I’m trapped in the vines”
“Look in my medikit for something that might get me out of these vines”
How do I accomplish this?
What do I code when they encounter the item?
And on the selection screen, what do I code to make it appear as a valid selection? invalid selection?
Many thanks. Go easy on me
Two ways:
One, you create a boolean (true/false) for each possible bit of equipment Then, when they find it, you can put *set knife true
and later have the choice as:
*selectable_if (knife=true) #Use the knife to cut the vines
Or, if the player can only ever have one thing, you can create a single variable for the player’s inventory item. Have *create inventory_item “nothing” in the startup
Then when you find something, you can change it by going
*set inventory_item “knife”
and write the choice options like
*selectable_if (inventory_item=“knife”) #Use the knife to cut the vines.
The ‘selectable_if’ command will grey the option out if you don’t meet the requirement, but you’ll still be able to see it. If you wanted the option hidden unless you meet the stat check, use an *if
Personally, I’d consider hiding the options that can’t be taken, but . . .
*choice
*if (have_knife = true) #Use knife.
*selectable_if (have_knife = true) #Use knife.
The first option would only be displayed if it could be chosen. The second would always appear, but it may not be selectable.
In case you ever need it, you could also hide options if they’ve been chosen before like this:
*choice
*if have_knife = true
*hide_reuse #Use knife.
Not tried the above myself, but it should work according to the wiki.
Good stuff y’all. Many Thanks. Didn’t expect such a fast response!
1 Like
You’re most welcome, and feel free to task anything else.
Does all code go into 1 .txt file? Because that’s what I’m doing. If there’s another, preferred way, do tell. I take advice and instruction easily.
Ideally, each chapter should be its own file. Easier to track things that way and such.
So, at the end of the chapter or the startup file, you’d have something like:
*goto_scene chapter_1
Others use the scene_list feature in the startup file though, but I don’t.
However, if your story is very small, I see no reason as to why you can’t keep it in one file.
That said . . . all of your ‘permanent’ switches/variables need to be created at the start of the startup.txt file, before the player sees any text.
So, depending on the variable/switch type, things like:
*create have_knife false
*create money 0
*create name “”
(Name is blank with only “” because players can fill it in via an ‘*input_text name’ command. In order to display the name later after it’s been chosen, you’d have ${name})
Temp variables that only last for one ‘scene’ or ‘file’, however, can be created in the relevant file. Simply replace *create with *temp.
You are so helpful. Hero of the day friend. Hope to share some worthy creativity soon. Thanks.