I was messing around with choicescript just and found a way to alter multiple variables with the change only requiring a single line of code.
For the test I used three variables;
[target] which determines which variable I want to change.
[hit_points and mana_points] the variables we want altered.
Then I coded a choice of being attacked by either a Bandit (lowers your hit_points) or a Demon (lowers your mana_points.)
Then all I need to do is write *set {target} %-5 at a single point then it will reduce whatever I choose as the target.
Test code is below;
*create hit_points 100
*create mana_points 100
*create target ""
*label fight
You have ${hit_points} HP remaining.
You have ${mana_points} MP remaining.
*choice
#The bandit hits me.
*set target "hit_points"
*goto next_scene
#The demon curses me.
*set target "mana_points"
*goto next_scene
*label next_scene
*set {target} %-5
*goto fight
Try this and whoever you pick as the attacker either your hit_points or mana_points will be reduced by 5%. Which I think it pretty neat and might be useful to others
Edit: This code also allows you to change booleans, strings and number variables all using that single target variable.
The code below using the target variable for changing a boolean, a string and a number variable!
*create hit_points 100
*create mana_points 100
*create bill false
*create ben false
*create target ""
*create partner_name ""
*label fight
You have ${hit_points} HP remaining.
You have ${mana_points} MP remaining.
*choice
#The bandit hits me.
*set target "hit_points"
*goto next_scene
#The demon curses me.
*set target "mana_points"
*goto next_scene
#Next test.
*goto new_scene
*label next_scene
*set {target} %-5
*goto fight
*label new_scene
You are with…
*choice
#Bill.
*set target "bill"
*goto another_scene
#Ben.
*set target "ben"
*goto another_scene
*label another_scene
*set {target} true
*if (bill)
*set partner_name "Bill"
You are with ${partner_name}.
*set target "partner_name"
*goto final_scene
*if (ben)
*set partner_name "Ben"
You are with ${partner_name}.
*set target "partner_name"
*goto final_scene
*label final_scene
After a few days ${partner_name} has to leave. They are replaced with…
*page_break Megan
*set {target} "Megan"
They are replaced with ${partner_name}.
*ending
Let me tell you about the miracle that is *params. Essentially, you can pass specific pieces of data to a *gosub and *gosub_scene.
Where to go?
*fake_choice
#Go to dinner
*gosub outing "dinner"
#Go to club
*gosub outing "club"
Such a good way to spend the night.
*ending
*comment Params down here takes the string passed from above.
*label outing
*params where
*if (where= "club")
You had a lovely time at the club.
*return
*elseif (where = "dinner")
You had a lovely time at dinner.
*return
If you’re familiar with other programming languages, it works like an argument for a function. The post that has a better explanation is here.
Nice trick @Nocturnal_Stillness . You can do really cool stuff when you start using that kind of redirection.
@StorybookParagon please note that params in goto and gosub are not “scoped” like in a function in most programming languages. Their name may collide with a temp or stat, and you may modify your data by mistake - I had some nasty bugs that way! But yes, it’s a miracle.
Yeah that works for the test. Now to experiment a little. Thanks!
EDIT: And it works for what I was after.
*create alan_rep 50
*create billy_rep 50
*create charlie_rep 50
*create alan_training 50
*create billy_training 50
*create charlie_training 50
*create target ""
*label start
Who do you want to train?
*choice
#Alan.
*set target "alan"
*goto increase
#Billy.
*set target "billy"
*goto increase
#Charlie.
*set target "charlie"
*goto increase
*label increase
*temp name target&"_rep"
*set {name} %+10
*temp training target&"_training"
*set {training} %+10
Please check your stats.
*goto start
For this example each NPC has two stats reputation and training and with that code you suggested I can change either or both for any of them reducing the lines of code required.