Roll20 uses cookies to improve your experience on our site. Cookies enable you to enjoy certain features, social sharing functionality, and tailor message and display ads to your interests on our site and others. They also help us understand how our site is being used. By continuing to use our site, you consent to our use of cookies. Update your cookie preferences .
×
Create a free account

Lookup Tables With Name

Howdy, I am interested in creating a monster harvest tool using the monster name rather than a number to access the entry.  I get that I could probably do it by using a lookup macro that passes a number to the table.  is there a more simple way to do it?
1738784794
timmaugh
Forum Champion
API Scripter
Hey, Solos... can you be a bit more specific about what you want? I'm not sure what you mean by "monster harvest tool" -- does that mean you want to ransack a monster's pockets after it has been defeated, or something else? Also, what would be the expected output from the process... a specific series of data? A fixed set of things? A randomized set of things? Regarding rollable tables, those are really just aggregations of single datapoints, so it's not going to be easy to have individual points in a single table where this point is connected to MonsterA and the next is connected to MonsterB while simultaneously interrogating those entries for other data about MonsterA or B. Again, depending on what you want as your outcome, you could have a separate table for each monster (a MonsterA table, a MonsterB table) that would give you a bit more flexibility, but the setup/overhead for that could be more than you want to take on. Of course, depending on what you want to do, there might be script-based approaches to the data. For instance, the Metascript Toolbox, ScriptCards, or RecursiveTables (among others) all have different ways to structure and/or retrieve content -- either from rollable tables or through other structures. I think for you to get the best options to fit your circumstances we'll need a bit more information.
Thanks for the quick response.  I would like to create a tool to make it easier to look up monster harvesting.  i have several PDF based tools or Thieves guild etc but want to make it easier by bringing it in game. Ideally I would have a query ?{Monster | Aarakocra, 1 |  Aartuk, 2 } ]Then instead of a table roll use the value generated by the query to index the table entry for that monster eg Entry 1 Aarkocra     Feather ...     Beak... Entry 2 Aartuk     Aartuk Sap... I suppose I could embed all the text in the query but it would be massive...
1738794132
timmaugh
Forum Champion
API Scripter
OK, if the results are always going to be the same (every time you harvest a  "Star Fleet Cadet" you get a Space Suit, a Quantum Defibrillator, a bottle of Liquid Space Angst, and an Unsent Letter Home [Class 2]), then you can manage that with a table and a single index number. But... Non-Table Approach You could also manage it with a library character with a bunch of ability entries. That way, you wouldn't need the number conversion at all. If the character "MonsterMule" had an ability named "StarFleetCadet", that could be structured: **Star Fleet Cadet** Space Suit Quantum Defibrulator Liquid Space Angst (Bottle) Unsent Letter Home (Class 2) You can normally reference that as: %{MonsterMule|StarFleetCadet} ...but if you need to use that in a query, the contents would break the query syntax (the query won't like the line break -- or a comma, a pipe, or a right brace). In that case, you can instead refer to these abilities with the Metascript Toolbox using a Fetch construction: %(MonsterMule.StarFleetCadet) That way, the contents are not expanded until *after* the query runs. Your query might look like: ?{Monster|Aarakocra|Aartuk|Star Fleet Cadet,StarFleetCadet|...} Put that in the Fetch command, and you end up with: %(MonsterMule. ?{Monster|Aarakocra|Aartuk|Star Fleet Cadet,StarFleetCadet|...}) To output that, you can put it in a roll template in a bangsy message and drop it into chat by including the ZeroFrame {&simple} tag: !&{template:default}{{name=Monster Harvest}}{{Results= %(MonsterMule. ?{Monster|Aarakocra|Aartuk|Star Fleet Cadet,StarFleetCadet|...})}} {&simple} Pick the option you want and you get: Table Approach If you really want to use tables, you can use the same Metascript Toolbox. You would use a 1) Fetch call to the table, placed into 2) a roll template, which 3) gets output using ZeroFrame's {&simple} tag. In this case, the Fetch construction to get an item from the table named "MonsterHarvest" is more like: @(table.MonsterHarvest.1) ...where "1" is the index position of the entry if you convert the weight of the entries to a number line. In other words, if all entries in the table are weighted at 1, then each number would represent a new entry: 1, 2, 3, etc. If the first item was weight 1 and the second was weight 10, then all numbers between 2 and 11 would point to the second item in the table. Bottom line: for your purposes, keep the weights at 1, and increment your references in your query. In this model, your query would look more like: ?{Monster|Aarakocra,1|Aartuk,2|Star Fleet Cadet,3|...} ...and you'd put it in the Fetch construction in place of where I have the number: @(table.MonsterHarvest. ?{Monster|Aarakocra,1|Aartuk,2|Star Fleet Cadet,3|...} ) Then there's the matter of what to include in that table entry. You have a limited textbox in the interface of the table to make this entry, so it can be hard to edit via that route. Here's what the Star Fleet Cadet entry would look like: **Star Fleet Cadet**{&nl}Space Suit{&nl}Quantum Defibrulator{&nl} Liquid Space Angst (Bottle){&nl} Unsent Letter Home (Class 2) Note that I use the ZeroFrame new line tags (the {&nl} bits in there). This gets around the double-line spacing something like %NEWLINE% will introduce (completely by virtue of going through the ZeroFrame processing -- it wouldn't normally do this). So now your command would look more like: !&{template:default} {{name=Monster Harvest}}{{Output=@(table.MonsterHarvest. ?{Monster|Aarakocra,1|Aartuk,2|Star Fleet Cadet,3|...} ) }}{&simple} ...and your output more like: Going this route, you could have another table that connected the index number to the monster name. That would mean a table of just monster names THAT IS KEPT IN SYNCH with the MonsterHarvest table (so 1 in both tables is the Aarakocra, 2 is the Aartuk, 3 is the Star Fleet Cadet, etc.). Let's call this other table just "MonsterTypes". That means that if you used Fetch to return the 3rd item: @(table.MonsterNames.3) ... you would get "Star Fleet Cadet". That means that we can use the *same query* to return a different piece of information for the monster that we can use in the title bar of the template: {{name=Harvesting @(table.MonsterTypes. ?{Monster|Aarakocra,1|Aartuk,2|Star Fleet Cadet,3|...} )}} Since you only have to include the full query the first time you use it, and since this usage would come before the "Output" line, your "Output" reference to the query would get much simpler. The final template statement would look like: !&{template:default}  {{name=Harvesting @(table.MonsterTypes. ?{Monster|Aarakocra,1|Aartuk,2|Star Fleet Cadet,3|...} )}}  {{Output=@(table.MonsterHarvest. ?{Monster} ) }}{&simple} That's a lot of info, so if anything is unclear, post back.
This is fantastic!  I will dig into it and get busy.  Really appreciate your help timmaugh!
1738941583
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
Non-API approach: If the harvest is the same for every monster of its kind, create an attribute on the character sheet called "harvest". You can then select any monster and post: @{selected|harvest} in chat to get the result. Players can do this by using @{target|harvest}
Thanks keith!