Open OtterlyAdorable opened 6 years ago
I would use something like this:
{ "resultPattern": "We are {groceryQty} groceries this week. Please go buy {var:item{var:num}}.", "variables": { "item1": "{purchaseList}", "item2": "{var:item1} {purchaseList}", "item3": "{var:item2} {purchaseList}", "item4": "{var:item3} {purchaseList}", "item5": "{var:item4} {purchaseList}", "item6": "{var:item5} {purchaseList}", "item7": "{var:item6} {purchaseList}", "item8": "{var:item7} {purchaseList}", "item9": "{var:item8} {purchaseList}", "item10": "{var:item9} {purchaseList}", "item11": "{var:item10} {purchaseList}", "item12": "{var:item11} {purchaseList}" }, "tables": [ { "name": "groceryQty", "entries": [ { "v": "out of", "set": { "num": "{dice:3d4}" }, "v": "low on", "set": { "num": "{dice:2d4}" } } ] } ] }
Thank you so much for your response!
I've got some of how this works hashed out, but I'm not sure how the items/purchase list are supposed to work. Can you explain the theory to me and I might be able to figure it out from there?
It's a recursive pattern (at least I intended this :-) ):
You may want to add a comma or linebreaks (\r\n) between purchaseList calls.
Thank you for your response!!
I broke up the ideas you gave into pieces to see if I could get each one working individually. I did manage to figure out how to get the grocery list to call last night--and even figure out how to get the commas in there and pick unique values by using {!purchaseList}. I used the variable list like you suggested, plus I added 2 tables: an Item table with an entry of each var:item#, and a purchaseList table for the grocery item options. When I call "resultPattern":"{item}", it selects a random {var:item#} from the item table and outputs lists of varying lengths, all unique values. So far, so good.
Then I started working on the "groceryTable" part you suggested, but I'm getting a weird result occasionally that maybe you can help me out with. I'm not sure my syntax is correct when I set up the "groceryQty" table, with the "v" value and "set" num quantity. The values don't seem to matching the set values, and occasionally the values won't be displayed at all--resulting in "We are grocieries this week" (however, it does still output the list at the end).
"tables": [
{
"name": "groceryQty",
"entries": [
"v": "out of",
"set": {
"num": "12"
},
"v": "low on",
"set": {
"num": "{dice:3d4}"
},
"v": "okay on",
"set": {
"num": "{dice:2d4}"
},
"v": "fully stocked on",
"set": {
"num": "{dice:1d2}"
}
]
},
We are okay on groceries this week. Please go buy Spaghetti.
This output should be at least 2 items (2d4 = minimum of 2)
We are fully stocked on groceries this week. Please go buy Lunch Meat, Juice, Eggs, Soup, Bread.
This output should only be 1 or 2 items
We are groceries this week. Please go buy Pizza.
This output doesn't have a value at all.
I cannot figure out why it's doing this.
So I just realized I got a little bit ahead of myself there.
It's disconnected because I'm not using the attached "num" value, I'm pulling the list from a totally separate table. I did this just to see if I could get the list working at all, and then added it to the table without remembering that I still need to have the value and the number connected.
So the real issue is that when I set the resultPattern to include {var:item{var:num}} (which should still call from the variable list just fine) I either get a proper value with this error:
We are low on groceries this week
{var:item<error calling non-existent variable 'num' from 'User-defined Generator JSON'>}
or I get a blank value with a literal variable
We are groceries this week.
{var:item9}
Try adding curly braces to complex entries:
"tables": [
{
"name": "groceryQty",
"entries": [
{ "v": "out of",
"set": {
"num": "12"
}
},
{ "v": "low on",
"set": {
"num": "{dice:3d4}"
}
},
{ "v": "okay on",
"set": {
"num": "{dice:2d4}"
}
},
{ "v": "fully stocked on",
"set": {
"num": "{dice:1d2}"
}
}
]
},
That was part of the problem, for sure. No more blank values, and it looks like the number is matching up properly to the value. We are almost there!!
However, I am still getting "{var:item#}" instead of the list.
This is my resultsPattern:
"resultPattern": "We are {groceryQty} groceries this week.\r\r{var:item{var:num}}",
I figured it out!!! I moved some things around. I thought maybe putting one variable inside another right in the resultPattern was causing the issue, so I tried moving the variables. It ended up looking like this:
{
"resultPattern": "{var:item}",
"variables": {
"item": "We are {groceryQty} groceries this week.\rPlease buy {var:item{var:num}}.",
"item1": "{!purchaseList}",
I don't know if this is very good practice, so if there's a more proper way to set this up, I'd love to know.
Other than that, it works!!!
Hey, so I used the Grocery Generator as a basis to create a much more complex Town Generator.
I feel like such a newbie, but I've never done this before. Do I just upload my generator for public use?
Congratulations!
You can create your own branch in this repository and upload your generator there. If you want more visibility and perhaps even feedback, you could announce the generator in the Campaign Logger Google+ group: https://plus.google.com/u/0/communities/109734413216289457602
I'm eager to see what you have come up with!
@evesala , I'm not sure how to do that. I looked up how to make a new branch, but either the method changed or I'm just totally missing something. =/
Ok, I think I got it.
I apologize if the issue name isn't very clear. I am super new to JSON, and I'm not even sure how to summarize what I'm trying to achieve.
I would like to be able to use one variable to base other variable generation upon.
For instance:
{groceryQty} table might look like, "out of" "low on" "good on" "fully stocked on"
If groceryQty = "out of", then {groceryList} would generate a string of 3d4 items from {purchaseList}. If groceryQty = "low on", then {groceryList} would generate a string of 2d4 items from {purchaseList}. If groceryQty = "good on", then {groceryList} would generate a string of 1d4 items from {purchaseList}. If groceryQty = "fully stocked on", then {groceryList} would output "No Groceries Needed".
Furthermore, if it's possible, I would love to add some "required" items to the list. It'd be even more awesome if this could be based on the {groceryQty} result.
If groceryQty = "out of", then {groceryList} would add "Pizza" to the list. If groceryQty = "low on", then {groceryList} would add "Salad" to the list. If groceryQty = "good on", then {groceryList} would add "Cheese-Its" to the list. If groceryQty = "fully stocked on", then {groceryList} would add nothing to the list.
If there happens to already be a way to do any of these things, I would really appreciate an example/tutorial.