2 Attachment(s)
Trying to beef up Story Templates. Help needed
If ANYONE here is a veteran Lua whiz, I could really use some big brain power. Moonwizard, you out there? *lights up the BatSignal*
Here is a visual representation of what I am trying to do:
Attachment 40151
Now here's the long version of my plan, in case anyone does have the ability to help and would like more data:
Within the software, we have a feature called Tables (where you can roll virtual dice and receive an outcome. These tables can have multiple columns forming their output.), and another feature called Story Templates (where you can write a story, and embed “callouts” to Tables.) When a “Generate Story” button is pressed within the Story Template, all the Table “callouts” you typed are replaced by the retrieved results from the Tables you were asking for. In practice, it would look like this in the Story Template before the button was pressed:
- The merchant had [Eye Color] eyes, and [NPC Interesting Feature].
Once the Generate Story button is pressed, a new record is created that replaces the Table callouts, it might look like this:
- The merchant had blue eyes, and a pink scar on both palms.
Furthermore, there is another layer to what is baked in out of the box, and these are called Reference Links. They let you recall something you have already retrieved from a given table, and would look like this at first:
- The merchant had [Eye Color] eyes, and [NPC Interesting Feature]. His <Eye Color> eyes quickly searched the scene ahead.
Once the Generate Story button is pressed, a new record is created that replaces the Table callouts, and ALSO retrieves data it already stored from the [Eye Color] Table Callout, in order to populate the <Eye Color> Reference Link with the same data. It might look like this:
- The merchant had green eyes, and a nervous twitch. His green eyes quickly searched the scene ahead.
I aim to provide a bit more functionality, in the form of a second type of Table Callout, and a second type of Reference Link. My callouts will look like {Table Callout} instead of [Table Callout], and my Reference Links will look like #Reference Link|Column Number# (where "Column Number" is a numerical digit) instead of <Reference Link>. This is intended to be additive, and not replace original functionality but augment it. (Though for prototype purposes, I have removed all original functionality from the code below. I'll add it back in when I get this working)
When I make a Table callout using the new method, I want the output of the table's different columns to be placed into discrete positions within an array, so I can later retrieve them separately with the new Reference Link. (The original system doesn’t let you do this: any time you use a Reference Link, it verbal-diarrheas every single column result from the initial Table callout) Here's an example of how I want to cherry-pick the column results from Table callouts under my added system:
Table A has 3 columns and 5 rows. When rolling for a result on Table A, no matter which of the 5 rows is rolled as the result, you will get output from all three columns of that row. So within the story template, let’s say we type:
{Table A}
#Table A|2#
#Table A|3#
The desired outcome would be that Table A’s output goes into an array, with each column occupying a different position. In the following two lines, we retrieve only what came from the second column of the original {Table A} callout, and on the third line we retrieve only what came from the third column.
Conceptually, I know what I want to do, and I feel like I am close, but visualizing what I need to do next with my code is boggling me… Any suggestions would be greatly welcome. I'll attach the code so far, and post it below too.