Technical Shenanigans (Patreon)
Content
Firstly, thanks to folks so far who've taken part in the opinion poll on the relationships structure. I really appreciate your feedback on the matter.
Secondly, I can now safely say I have a system that works within the choicescript structure that effectively allows me to record and recall player choice in one single string variable! Which will be enormously helpful when implementing the somewhat complex relationship structure I talked about yesterday, without overwhelming the game with variables.
Basically, it works like this:
When a player/reader makes a choice that choice is assigned a string (letter or numerical value stored as a script rather than an integer/float). This is concatenated or adjoined onto the end of a master memory string variable. In the test situation I have above this is variable is labelled event_memory.
Concatenation is just that in essence, adding a string value to a pre-existing variable, or joining two string variables together to construct a third. You can check out the ChoiceScript Wiki here for more info.
For my example I've employed a temporary storage variable temp_memory in order to make sure the stored string value is not overwritten by the incoming addition. So when adding a new event to the memory variable I first temporarily save that value in the temporary memory then concatenate the temp and the new string to reform the event_memory variable with it's latest entry.
Stored and sorted!
Now the recall.
This is done using a subroutine and parameter combination. In the test example above I'm manually specifying the event I wish to recall from a choice list, but in the main game I can set up a system to determine the right entry for the purpose of the moment.
This is the subroutine. The entry value (which tells the subroutine which entry in the memory to look up) is sent to the subroutine by the parameter addition to the standard *gosub command. If you look at the second image you'll be able to see that just after I specify the subroutine I'm sending the system to I make the addition of a number, in the test example this is 1 or 2. This is then written into a temporary variable or parameter called entry within the subroutine using the *params command.
For more information on Parameters check out this page of the ChoiceScript Wiki:
The subroutine uses entry to select the right character from the event_memory string by counting the characters within the string and storing the correct character value in the temporary variable checker. This is done by using the # command as seen in the example above.
The subroutine then checks the checker with a preset list and writes the result in numerical form to another temporary variable called memory_return. It's likely that in the main implementation of this method I'll set this returning variable as a full variable and not a temporary one, but it just worked out better to test it with a temp.
Referring back to the second image again, you can see that memory_return is then read and used to print out the appropriate information in the main text. Which when all is said and formatted looks like this:
Please ignore my terrible wording in the formatted shot.
TaDah! No more ridiculous lists of variable, upon variable, upon variable to keep track of what you lovely readers get up to. Now I can store it all in one, and recall your past deeds at any point I need to!
Make good choices now!
Files
Previews only