As the title suggests, I'm trying to figure out is I can make a macro inside of a macro. More specifically, I'm trying to make randomized ramifications to enter a village, a certain set of skills to be specific. I'm using Sugarcube, by the way
It should be noted that I am very new to coding. Any help would be much appreciated.
Comments
I believe so. The very rough outline I have so far is this:
<<if $<<either "Fishing", "Hunting", "Foraging", "Field Medicine" or "Animal Husbandry'', "Farming", "Sewing", "Child Rearing">> is true>> Accepted
<<elseif $<<either "Fishing", "Hunting", "Foraging", "Field Medicine" or "Animal Husbandry", "Farming", "Sewing", "Child Rearing">> is false>> Denied
<</if>>
This probably looks as rough as sand paper but, I guess it's better than nothing?
a. the "Fishing", "Hunting", "Foraging", "Field Medicine", etc are meant to be the names of different variables or properties in the story.
b. each variable/property can be either true or false.
c. you want to be able to test if one? / some? / all? of the variables/properties are equal to true (or false).
Kudos for specifying which story format you're using—it's SugarCube, BTW. You really should also specify the version as well, however, as that does make a difference.
For now, I'll assume that you're using SugarCube v1 (probably v1.0.34, if you're using Twine 2 v2.0.11).
I'd suggest starting by reading over SugarCube's documentation (docs for v1 or docs for v2).
You cannot invoke a macro from within the argument list of another macro, no. That's not really an issue here, since, based on your description, that isn't really what you need to do.
You're probably looking for the either() story function, which you can find within SugarCube's documentation (see above).
If these things will be story variables containing boolean values which you want to randomly select one one to test, then you probably want something like the following: (based on the random selection in your pseudo-example) The invocation of either() will randomly select the result of one of the given expressions and return its value. Based on the truthiness of that value, the <<if>> will execute either the 'Accepted' or 'Denied' code paths.
Note: The $FieldMedicine and $AnimalHusbandry variables are ganged together via the logical-OR operator, since that's what your pseudo-example showed. If that was a mistake, then simply replace the logical-OR operator with a comma, just like the others.
Error: <<if>>" bad conditional expression in <<if>> clause: Unexpected identifier.
My code is:
<<if $s-skill either (
$Fishing, $Hunting, $Foraging, $Field Medicine
)>>
Accepted
<<else if $d-skill either(
$Animal Husbandry, $Farming, $Sewing, $Child Rearing
)>>
Accepted
<<else>>
Denied
<</if>>
By the way, thank you both for all of the help.
Now I have to ask, what is the following supposed to be doing: Specifically, this bit: A variable immediately followed by a function call, in a conditional expression. Are you trying to do an assignment there or what?
Also, as noted in its documentation, the ELSE-IF tag of the <<if>> macro is spelled <<elseif>>—no space.
As for what exactly I want it to be doing, I want to have the code select one of the four skills in each category, therefore giving the player a higher chance of winning the 'lottery". Honestly, I don't even know if what I'm trying to do is feasible.
May we assume that the categories and skills contained within are the following?
If the character must have both of the skills, randomly picked from the categories, then try something like the following: Basically, the character must have a randomly chosen skill from both category A and category B.
Elsewise, if the character only needs one of the skills, randomly picked from the categories, then try something like the following: Basically, the character must have a randomly chosen skill from either category A or category B.
The only difference between the two is the logical operator used to conjoin the two either() invocations—logical-AND for the former and logical-OR for the latter.