Hello everyone,
My name is Steve, I’m a pretty fresh face here with CoG. I recently discovered this fantastic library after stumbling across the Way Walker series on the iTunes app which, naturally, lead my curiosity to the website. Upon discovering Choicescript, I have been dabbling at creating my own work as interactive storytelling is every bit of a dream I’ve wanted to achieve; I wish I would’ve found it sooner. Which comes to my thanks, truly. There are periods in a person’s life where they can’t seem to figure out which path they should pick or which they should return to and it’s a definite bummer, to say the least. I’ve found myself in a very complicated period in my life as such. Choicescript has revived inspiration in me that I was afraid was lost and, for that, I am grateful.
Functions
There was something I have thought about while writing and, perhaps it’s due to the lack of experience, I’ve found that building and math sequences around my story can become cluttered depending on how many variables are involved. I understand the limitations as well as the simplicity of Choicescript which, surprisingly, has been very refreshing; but I may have a suggestion that could potentially “clean up” this problem: functions.
Below are three math functions that I planned to use frequently throughout my story. As you can probably tell, depending on the frequency, this can create huge blocks of math that can clutter organization; plus trying to relocate the actual sequence to copy and paste:
/**Average*/
*set power round((((((((str)+(dex))+(int))+(wis))+(cha))+(per))) / 6)
/**Lowest Stat*/
*if (((((str<=dex) and (str<=int)) and (str<=wis)) and (str<=cha)) and (str<=per))
*set warrior true
*if (((((dex<=str) and (dex<=int)) and (dex<=wis)) and (dex<=cha)) and (dex<=per))
*set rogue true
*if (((((int<=str) and (int<=dex)) and (int<=wis)) and (int<=cha)) and (int<=per))
*set mage true
*if (((((wis<=str) and (wis<=dex)) and (wis<=int)) and (int<=cha)) and (int<=per))
*set cleric true
*if (((((cha<=str) and (cha<=dex)) and (cha<=int)) and (cha<=wis)) and (cha<=per))
*set bard true
*if (((((per<=str) and (per<=dex)) and (per<=int)) and (per<=wis)) and (per<=cha))
*set gambit true
/**List*/
*if (warrior)
*set weakest &"warrior"
*set comma true
*if (rogue)
*if (warrior) and ((((not (mage)) and (not (cleric))) and (not (bard))) and (not (gambit)))
*set weakest &" and rogue"
*set check true
*if (not (check))
*if (comma)
*set weakest &", "
*set weakest &"rogue"
*set comma true
*if (mage)
*if ((warrior) or (rogue)) and (((not (cleric)) and (not (bard))) and (not (gambit)))
*set weakest &" and mage"
*set check true
*if (not (check))
*if (comma)
*set weakest &", "
*set weakest &"mage"
*set comma true
*if (cleric)
*if (((warrior) or (rogue)) or (mage)) and ((not (bard)) and (not (gambit)))
*set weakest &" and cleric"
*set check true
*if (not (check))
*if (comma)
*set weakest &", "
*set weakest &"cleric"
*set comma true
*if (bard)
*if ((((warrior) or (rogue)) or (mage)) or (cleric)) and (not (gambit))
*set weakest &" and bard"
*set check true
*if (not (check))
*if (comma)
*set weakest &", "
*set weakest &"bard"
*set comma true
*if (gambit)
*if (((((warrior) or (rogue)) or (mage)) or (cleric)) or (bard))
*set weakest &" and gambit"
*set check true
*if (not (check))
*if (comma)
*set weakest &", "
*set weakest &"gambit"
*set comma true
The idea of the functions is simple: build “wrappers” for these types of algorithms. It’s as easy as mapping these guys once and using a simple call on them, like a “packaging” tool. On top of this, if your variables change, you don’t have to go back and input different variables on a whole new instance. I believe I have a very simple format that correlates with Choicescript’s logic and wouldn’t be too intimidating to users. Let’s use those three, previous algorithms as examples:
Basic Wrappers
Basic wrappers are one-time calls with (all functions I’m talking about implementing are simple void statements, for those familiar with Java) concrete variables that you don’t plan to change the name of. For my example I’m using strength, dexterity, intelligence, wisdom, charisma and perception as variables that will stay the same regarding these functions, we’re just setting their values to something new as we call it.
/**Average*/
*func avg
*set power round((((((((str)+(dex))+(int))+(wis))+(cha))+(per))) / 6)
//call this function
*avg
/**Lowest Stat*/
*func lowest_stat
*if (((((str<=dex) and (str<=int)) and (str<=wis)) and (str<=cha)) and (str<=per))
*set warrior true
*if (((((dex<=str) and (dex<=int)) and (dex<=wis)) and (dex<=cha)) and (dex<=per))
*set rogue true
*if (((((int<=str) and (int<=dex)) and (int<=wis)) and (int<=cha)) and (int<=per))
*set mage true
*if (((((wis<=str) and (wis<=dex)) and (wis<=int)) and (int<=cha)) and (int<=per))
*set cleric true
*if (((((cha<=str) and (cha<=dex)) and (cha<=int)) and (cha<=wis)) and (cha<=per))
*set bard true
*if (((((per<=str) and (per<=dex)) and (per<=int)) and (per<=wis)) and (per<=cha))
*set gambit true
//call this function
*lowest_stat
/**List*/
*func weakest_list
*if (warrior)
*set weakest &"warrior"
*set comma true
*if (rogue)
*if (warrior) and ((((not (mage)) and (not (cleric))) and (not (bard))) and (not (gambit)))
*set weakest &" and rogue"
*set check true
*if (not (check))
*if (comma)
*set weakest &", "
*set weakest &"rogue"
*set comma true
*if (mage)
*if ((warrior) or (rogue)) and (((not (cleric)) and (not (bard))) and (not (gambit)))
*set weakest &" and mage"
*set check true
*if (not (check))
*if (comma)
*set weakest &", "
*set weakest &"mage"
*set comma true
*if (cleric)
*if (((warrior) or (rogue)) or (mage)) and ((not (bard)) and (not (gambit)))
*set weakest &" and cleric"
*set check true
*if (not (check))
*if (comma)
*set weakest &", "
*set weakest &"cleric"
*set comma true
*if (bard)
*if ((((warrior) or (rogue)) or (mage)) or (cleric)) and (not (gambit))
*set weakest &" and bard"
*set check true
*if (not (check))
*if (comma)
*set weakest &", "
*set weakest &"bard"
*set comma true
*if (gambit)
*if (((((warrior) or (rogue)) or (mage)) or (cleric)) or (bard))
*set weakest &" and gambit"
*set check true
*if (not (check))
*if (comma)
*set weakest &", "
*set weakest &"gambit"
*set comma true
//call this function
*weakest_list
With variables
Using variables is actually a pretty simple concept for Choicescript. All variables are, when attached to a function, is elements to use inside of that particular function. This can range from the local variables you want to use to even having a string (which I’m using for the list example). The benefit of this system is that you can change all your variables throughout your story while holding onto the core methods you built previously. The only downfall I see from this is the number of variables you’re using as you will be tied to whatever original number of variables you built for that function.
/**Average*/
*func avg n1 n2 n3 n4 n5 n6 x1
*set x1 round((((((((n1)+(n2))+(n3))+(n4))+(n5))+(n6))) / 6)
//call this function
*avg str dex int wis cha per power
/**Lowest Stat*/
*func lowest_stat n1 n2 n3 n4 n5 n6 x1 x2 x3 x4 x5 x6
*if (((((n1<=n2) and (n1<=n3)) and (n1<=n4)) and (n1<=n5)) and (n1<=n6))
*set x1 true
*if (((((n2<=n1) and (n2<=n3)) and (n2<=n4)) and (n2<=n5)) and (n2<=n6))
*set x2 true
*if (((((n3<=n1) and (n3<=n2)) and (n3<=n4)) and (n3<=n5)) and (n3<=n6))
*set x3 true
*ifif (((((n4<=n1) and (n4<=n2)) and (n4<=n3)) and (n4<=n5)) and (n4<=n6))
*set x4 true
*if if (((((n5<=n1) and (n5<=n2)) and (n5<=n3)) and (n5<=n4)) and (n5<=n6))
*set x5 true
*if if (((((n6<=n1) and (n6<=n2)) and (n6<=n3)) and (n6<=n4)) and (n6<=n5))
*set x6 true
//call this function
*lowest_stat str dex int wis cha per warrior rogue mage cleric bard gambit
/**List*/
*func weakest_list n1 n2 n3 n4 n5 n6 x1 x2 x3 x4 x5 x6
*temp check false //notice a variable is created specifically for the function instead of having it outside, more for organizational purposes.
*if (n1)
*set weakest &x1
*set comma true
*if (n2)
*if (n1) and ((((not (n3)) and (not (n4))) and (not (n5))) and (not (n6)))
*set weakest &" and "&x2
*set check true
*if (not (check))
*if (comma)
*set weakest &", "
*set weakest &x2
*set comma true
*if (n3)
*if ((n1) or (n2)) and (((not (n4)) and (not (n5))) and (not (n6t)))
*set weakest &" and "&x3
*set check true
*if (not (check))
*if (comma)
*set weakest &", "
*set weakest &x3
*set comma true
*if (n4)
*if (((n1) or (n2)) or (n3)) and ((not (n5)) and (not (n6)))
*set weakest &" and "&x4
*set check true
*if (not (check))
*if (comma)
*set weakest &", "
*set weakest &x4
*set comma true
*if (n5)
*if ((((n1) or (n2)) or (n3)) or (n4)) and (not (n6))
*set weakest &" and "&x5
*set check true
*if (not (check))
*if (comma)
*set weakest &", "
*set weakest &x5
*set comma true
*if (n6)
*if (((((n1) or (n2)) or (n3)) or (n4)) or (n5))
*set weakest &" and "x6
*set check true
*if (not (check))
*if (comma)
*set weakest &", "
*set weakest &x6
*set comma true
//call this function
*weakest_list str dex int wis cha per "warrior" "mage" "rogue" "cleric" "bard" "gambit"
Again, really the purpose of introducing functions to Choicescript is mostly for organizational and time-management purposes. I believe this can save people a good chunk of time trying to sift through equations they’ve built previously and having to copy and paste them while also consolidating a lot of lines in text.
Copyright
I am fairly new to storytelling and brand new to the idea of publishing said works. I had a quick question regarding copyright and references other works within your story. Is there copyright to be followed when referencing these works? For example “Josh listened to Linkin Park all the time when he was younger.” or “Bridge to Terebithia was Anne’s favorite book as a child.” I’m just not familiar with copyright in literature as most of my knowledge is related to music.
And that’s all I have! Comments, questions, concerns? I’m open to feedback! Thank you for your time