The first choice determines what the second set of choices will be but the choice 2’s answers keep replacing choice 3’s answers as well as omitting the text before it. Did I input something wrong?
Welcome! For starters, there has to be a *goto after each option in a choice; it looks like you only have it under the last option in each choice. But if I choose to boost strength, I need a goto, and if I choose to boost agility, I need a goto, even if they’re the same one (which they usually would be, though they certainly don’t have to be).
I have a situation where I have a number of dialogue choices (1 - 8). Choice 8 moves the scene on, choices 1-7 are dialogue loops which go back to the choice menu. 5 of the options are always visible but dialogue options 6 and 7 are contingent on previous events
It looks like this.
*label choice_loop
*choice
*disable_reuse #Talk about A
text
*goto choice_loop
*disable_reuse #Talk about B
text
*goto choice_loop
*disable_reuse #Talk about C
text
*goto choice_loop
*disable_reuse #Talk about D
text
*goto choice_loop
*disable_reuse #Talk about E
text
*goto choice_loop
*if (variable_1 = 1)
*disable_reuse #Talk about F
text
*goto choice_loop
*if (variable_2 = 1)
*disable_reuse #Talk about G
text
*goto choice_loop
#You don't want to talk about the others.
*goto next_scene
Now the last option - to move the scene onwards I want to change the wording based on if you have exausted all other dialogue options
So if you have exausted all options it would say “There is nothing else to talk about.” but if there were still options availability you don’t want to chose it will say “You don’t want to talk about the others.”
Now I know how to do this if all other dialogue options were selectable at all times, you could just use a simple count which goes up for each dialogue choice and a check to see if the max count has been reached then change the text of the final choice depending on that, using e.g. multireplace or various other ways
But my problem is that the “max” dialogue choices in this instance range from 6 to 8 depending on previous choices. So my question is - 1) is there a way to just code a check to see if all other dialogue choices have been exhausted? and 2) if this is not possible could anyone think of a work around?
you could use a numeral temp and multireplace. (for this assume F and G can’t show up in the same playthrough)
so
*temp talkywalky 0
*label choice_loop
*choice
*disable_reuse #Talk about A
*set talkywalky +1
text
*goto choice_loop
*disable_reuse #Talk about B
*set talkywalky +1
text
*goto choice_loop
*disable_reuse #Talk about C
*set talkywalky +1
text
*goto choice_loop
*disable_reuse #Talk about D
*set talkywalky +1
text
*goto choice_loop
*disable_reuse #Talk about E
*set talkywalky +1
text
*goto choice_loop
*if (variable_1 = 1) *disable_reuse #Talk about F
*set talkywalky +1
text
*goto choice_loop
*if (variable_2 = 1) *disable_reuse #Talk about G
*set talkywalky +1
text
*goto choice_loop
#@{(talkywalky =5) There's no one else to talk to| You don't want to talk about the others}.
*goto next_scene
they are triggered by conditions outside of this code snippet.
The only workaround I can currently think of is to have the same variables that allow F and G to be conditioned to increase the “max count”
waaaaait what if:
*temp talkywalky 0
*temp talkywalkytrigger 5
*if variable_1 = 1
*set talkywalkytrigger + 1
*if variable_2 = 1
*set talkywalkytrigger + 1
All the rest of the code here
#@{(talkywalky = talkywalkytrigger) There's no one else to talk to| You don't want to talk about the others}.
*goto next_scene
Bit of ring rust showing up. Is there a reason why my quick and random test have stopped working? Tried to run it on my new WIP and it says Error: couldn’t open web/mygame/scenes/startup.txt. Tried it with the Parenting ones and it says the same thing.
It’s been a while since I’ve downloaded an up to date version of ChoiceScript, but I would be terribly surprised if the answer has changed: I’ve always been able to keep multiple ChoiceScript versions side-by-side, each in their own folder. I’ve never deleted any of them, and never had a conflict.
That said, your original error message (couldn’t open web/mygame/scenes/startup.txt) is almost certainly possibly due to an update in your web browser that changes the way locally hosted files (index.html, quicktest.html, randomtest.html, etc.) can load other files (startup.txt, etc.).
Download a new ChoiceScript installation, read the installation instructions three times (because they’re almost certainly different than what you’ve done with past versions), then follow the instructions and try it with the new version.
I know it’s been a while already, but a couple of posts above, the guys were trying to figure out the best way to determine the minimum and maximum variable in a given set. So I just wanted to share my solution:
I created a subroutine that accepts as many arguments as you want and it will return the one with the highest value.
Name: max()
Signature: gosub max() arg_1 arg_2 arg_3 etc
Description: selects the highest value in a set
Arguments:
arg_1: Integer: number of variables to be compared;
arg_2: String: name of the variable (inside quotation marks), e.g.: “honesty”;
any subsequent argument follows the pattern of the second one.
Return:
output_1: String: name of the highest variable, the value of the variable can be retrieved with curly brakets, i.e. {output_1}
output_2: Boolean: returns true if there was a tie during testing
*temp honesty 0
*temp courage 0
*temp intelligence 0
*temp influence 0
*rand honesty 0 100
*rand courage 0 100
*rand intelligence 0 100
*rand influence 0 100
*temp output_1 ""
*temp output_2 ""
*gosub max() 4 "honesty" "courage" "intelligence" "influence"
*if output_2 = false
The stat with the highest value is ${output_1} at ${{output_1}} points.
*else
There was a tie!
*finish
*label max()
*params
*temp test_length param[1]
*temp maxval param[2]
*temp test_index 3
*temp tie false
*if (test_length < 2)
*return
*label max_foreach
*if ({maxval} > {param[test_index]})
*goto max_continue
*elseif ({maxval} < {param[test_index]})
*if (tie = true)
*set tie false
*set maxval param[test_index]
*goto max_continue
*else
*set tie true
*goto max_continue
*label max_continue
*set test_index +1
*if (test_index <= test_length)
*goto max_foreach
*comment return result
*set output[1] maxval
*set output[2] tie
*return
You can tweak it so that in case of a tie it returns the value of the other variable as well. But it’s never going to be perfect For example if there is a tie between three variables.
You can tweak it to return the lowest variable instead.
If testing local variables, make sure the subroutine is in the same file.
It’s actually really cool. You need to make sure that the name of the variable you’re trying to change is completely included as a text in a different string.
Then you need to concatenate the active friend with the _friendscore appendix, so the complete name is the variable you wish to modify. I believe this is the only step you missed out on in your example.
Thanks everyone. I managed to get it working and it is nice!
Just a heads up, as szaal is indicating, if you want to display the text/value of a variable you create in this way it has to go in the double curly brackets (or however many levels you have)
so
${friendscore_modifier_text}
will show the name of the concatenated variable e.g. “alice_friendscore”