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 .
×

1e Trading Post API

Trading Post Command&nbsp; !shop-menu Works directly with 1e character sheet by deducting expenses and adding purchased items to your items list on the sheet. The API supports several store types, including trading posts, outfitters, smiths and armorers, stables, and herbalists, along with preset stores such as the Players Handbook store and Hommlet from Greyhawk. It can generate stores with different sizes, settlement types, focuses, and local tags, and those factors affect both what appears in stock and how prices are modified. The system handles ordinary gear, armor, weapons, ammunition, herbs, clothing, provisions, tack, transport, livestock, and trinkets, while also allowing GM-created stores and store-specific inventories. Players can build their character sheet inventory when they create their characters instead of manually entering in each item. It also includes a full cart and checkout workflow tied to a selected token or character. Items can be added to and removed from a cart, totals are calculated automatically, and purchases write back into the character’s repeating equipment. Currency is handled in gp, sp, and cp, stock is reduced after successful purchases, and the script prevents checkout when stock is unavailable or the buyer lacks funds. For generated and local stores, non-custom body armor can require a fit roll before purchase, while the Players Handbook store is exempt from that check. Beyond shopping, the API includes restocking and campaign-management tools. Stores can refresh over time, days can be advanced to trigger restocks, and GMs can create, audit, list, refresh, or reset stores through commands. Horses and transport animals can generate with persistent traits, barding can appear in stables, herbalists avoid armor stock, and low-level armor can appear in regular trading post style stores. Altogether, the script is meant to function as a reusable local economy system for 1E play rather than just a static item list. <a href="https://github.com/earmarkaudiology-png/Trading-Post/blob/main/shop" rel="nofollow">https://github.com/earmarkaudiology-png/Trading-Post/blob/main/shop</a>
1774503356
vÍnce
Pro
Sheet Author
That's so cool.&nbsp; I bought a Dagger and it added it to my currently selected token's linked character as Gear and it deducted the gold.
It is awesome! All of these API I've been working on work great. They take away a lot of the bookkeeping. Try out the Blacksmith and build some armor.&nbsp; Not much interest is seems though. Maybe I should do 5e stuff.&nbsp;
Here is a list of current 1e API's and their updated files in github earmarkaudiology-png/BlackSmith-1e 4 commits earmarkaudiology-png/Jeweler-1e 2 commits earmarkaudiology-png/Timekeeper 2 commits earmarkaudiology-png/Tailor-Shop 1 commit earmarkaudiology-png/Leather-Shop 1 commit earmarkaudiology-png/Trading-Post 1 commit earmarkaudiology-png/Monster-Loot- 1 commit earmarkaudiology-png/Retainers-1e- 1 commit earmarkaudiology-png/Roll20-campaign-... 1 commit
1774549162

Edited 1774549261
Tilt
Pro
Rotto, I am interested in using a few of these but I seem to be getting an error when I try to install the Monster Loot API.&nbsp; I am creating a new script, copy and pasting the code in there.&nbsp; However, my sandbox then gives me an error "ReferenceError: treasure is not defined".&nbsp; &nbsp; &nbsp;Do you know by chance what I may be doing wrong?&nbsp; Thank you in advance
You need to have tokenmod and chatsetattr. I'll be making some updates on the mods tonight so check back to github for latest version Here is what I have in my game.
you might want to check you delete&nbsp; !treasure at the top of the script
ROTTO said: you might want to check you delete&nbsp; !treasure at the top of the script That was it!&nbsp; I also see that you removed it from the code on your side also.&nbsp; &nbsp;Very nice, I played with it and it is great.&nbsp; &nbsp;Thank you very much!&nbsp; &nbsp; &nbsp;I am wrapping up our Dragonlance game in the next few sessions, but when we start our next campaign, I can see myself using at least a few of those.&nbsp; Especially excited to see how the exp one works and to play with it. Thanks agian
The XP one is great. First step is select your tokens for the session. Then you can start adding XP from coins and monsters etc as you go. A nice feature is you can choose if you want the lower XP for a magic item or when you sell it.&nbsp;
BTW here is the latest.&nbsp; I added in some more features <a href="https://github.com/earmarkaudiology-png/Roll20-campaign-XP-manager-for-1e-AD-D./blob/main/updated%20Ver2" rel="nofollow">https://github.com/earmarkaudiology-png/Roll20-campaign-XP-manager-for-1e-AD-D./blob/main/updated%20Ver2</a>
1774584721

Edited 1774584743
vÍnce
Pro
Sheet Author
ROTTO said: you might want to check you delete&nbsp; !treasure at the top of the script I like having the API command(s) included with scripts.&nbsp; I just comment them out. // !treasure&nbsp;
I deleted it in the script
1779432993

Edited 1779433085
HI Rotto,&nbsp; I've incorporated this into my campaigns, but I discovered something (and it may probably be inconsequential): Under Equipment, your script inserts repeating_weapon_$X_equipment_type as a string while when I enter an equipment manually and choose the weapon type from the dropbox, the character sheet enters it as a numeric value. I discovered this while writing an API/Mod to allow a character or DM to bring up ammo possessed by the character to look for&nbsp; repeating_weapon_$X_equipment_type and then checking to see if the repeating_equipment_${id}_equipment_item contained a number of options, like arrow, hammer, etc. Here's a snippet of my original code. The first block shows how eqTest is defined by&nbsp; repeating_weapon_$X_equipment_type and eqName is defined by&nbsp; repeating_equipment_${id}_equipment_item . I've bold and underlined the parts in the code concern. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;let eqTest = ( getAttrByName( charID, ` repeating_equipment_${id}_equipment_item ` ) || "" ).toLowerCase(); let eqName = getAttrByName( charID, ` repeating_equipment_${id}_equipment_item ` ) || "" and those variables are used here. Arg is "m" for missiles (I have another part of this that lists all equipment): &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if (arg === "m") { //filter for arg missile first and eqType is weapon of "1" //Use == here because === limits to text only. I think TradingPost enters number as text but choosing from character sheet enters as number . if (eqType == "1") { if ( eqTest.includes("arrow") || eqTest.includes("bolt") || eqTest.includes("quarrel") || eqTest.includes("rock") || eqTest.includes("bullet") || eqTest.includes("stone") || eqTest.includes("javelin") || eqTest.includes("spear") || eqTest.includes("dart") || eqTest.includes("dagger") || eqTest.includes("club") || (eqTest.includes("hammer") &amp;&amp; !eqTest.includes("lucern")) || (eqTest.includes("axe") &amp;&amp; eqTest.includes("hand")) || (eqTest.includes("axe") &amp;&amp; eqTest.includes("throw")) ) { isMissile = "y"; } else { isMissile = "n"; } if (isMissile === "y") { xMissiles = xMissiles+1; sendChat( "System", "Missiles: " + xMissiles + ": " + eqName + "&lt;br&gt; Qty: " + eqQty + " isMissile: " + isMissile + " eqType: " + eqType ); } } } So originally, I had if (eqType === "1"). The cleric Fodder Dave (who has been a &amp;^%$ing PITA since kindergarten in the darn freaking 60s, LOL) had a hammer entered from the character sheet, but it would not show: Fadder Dave arg: m Found 7 equipment rows. arg represents the argument for the command, and yes, all he had was 7 items listed in his equipment. I then went to the Trading Post script and added a hammer that way. Puzzlingly, while his equipment showed two hammers. The top one in this screenshot is the one I added via the character sheet itself, the bottom was added via your Trading Post: However, the result I got with&nbsp;eqType === "1" was: Fadder Dave arg: m Found 8 equipment rows. Missiles: 1: Hammer Qty: 1 isMissile: y eqType: 1 Only one hammer showing. When I changed&nbsp;eqType === "1" to just 2 equal signs to force numeric only to both string and numeric, I got what the 2 hammers I expected: Fadder Dave arg: m Found 7 equipment rows Missiles: 1: Hammer Qty: 1 isMissile: y eqType: 1 Missiles: 2: Hammer Qty: 1 isMissile: y eqType: 1 So, I am pretty sure that there is a difference in how your TRading Post enters&nbsp; repeating_equipment_${id}_equipment_item &nbsp;as compared to doing it from the sheet. I hope I was able to make the above intelligible. I really don't think it matters except to idiots like me getting into this sort of thing.
1779434394

Edited 1779444589
Vince, Following from my last post, I get another error when I run my script with an argument to list all things. A lot of the items that show here were added from the character sheet some time ago, and others were added recently under sheet v1.695. I've only checked Gear and Weapon, but it appears that defaulting to Gear enters a either null value or a zero length string for&nbsp; repeating_equipment_${id}_equipment_type . See the italicized results below following "Potions of Healing". The output for each line is eqType (repeating_equipment_${id}_equipment_type)&nbsp;and then Eqpt (repeating_equipment_${id}_equipment_item). Zeffiro Zirconyd arg: a Found 23 equipment rows. System: eqType: 1 Eqpt: Short Sword eqType: 1 Eqpt: Sling eqType: 1 Eqpt: Sling Bullet eqType: 4 Eqpt: Thieves’ picks &amp; tools eqType: 3 Eqpt: Ring of Shadows eqType: 2 Eqpt: DO NOT EDIT/ADD! Use Armor Details above System: eqType: 2 Eqpt: Leather eqType: 0 Eqpt: Flasks of oil eqType: 0 Eqpt: Iron spike eqType: 0 Eqpt: Tinder box eqType: 1 Eqpt: Jewelled dagger, 20 g.p, eqType: 0 Eqpt: Garlic bud System: eqType: 0 Eqpt: Umbrella (from Squilaw) eqType: 0 Eqpt: Blank paper eqType: 0 Eqpt: Boots, high soft eqType: 0 Eqpt: Cloak eqType: 0 Eqpt: Rations, 2 weeks eqType: 0 Eqpt: Potions of Healing System: eqType: Eqpt: Backpack eqType: Eqpt: More test stuff eqType: 1 Eqpt: New weapon to test type eqType: Eqpt: Test gear added from All tab eqType: 0 Eqpt: Test added chage gear Of the italicized entries: The "new weapon to test type" shows the number 1 is added when you enter a new item. The first result was entered from the Gear tab. The 3rd item from the All tab where "gear" is chosen as a default. In those cases, the sheet does not fill&nbsp; repeating_equipment_${id}_equipment_item &nbsp;(a null value) or enters a&nbsp;a zero length string The last result was added and had "gear" entered as default, but then changed to "weapon" and then back to "gear". In this case, the 0 is entered as one would expect. I don't know if anyone else is relying on the equipment type for any scripts, but this could cause some issues. :-)
I'll look into this..thanks.
<a href="https://github.com/earmarkaudiology-png/Trading-Post/blob/main/TradingPost1E_v0.3.5_equipment_type_normalized.txt" rel="nofollow">https://github.com/earmarkaudiology-png/Trading-Post/blob/main/TradingPost1E_v0.3.5_equipment_type_normalized.txt</a> Changed the Trading Post equipment row creation so equipment_type is normalized before being written. Changed the existing-row comparison so blank/missing type is treated as "0" instead of causing a mismatch. This should not rewrite or damage existing character sheets. It only affects how Trading Post sets and compares the equipment type when adding/stacking items.
1779462880

Edited 1779463564
vÍnce
Pro
Sheet Author
Caveat, my API knowledge is VERY limited...&nbsp; character sheets were designed to function without Roll20's API.&nbsp; AFAIK, the API has no clue what the default value is for a sheet attribute if it's only set in HTML.&nbsp; Either the sheet needs to set these values from sheetworkers (in addition to the HTML) to "expose" them to the API or you must set a default value from the API and/or both. ie they are undefined until they are created/edited by a user. The vast majority of sheet attributes are only created in HTML.&nbsp; I do assign values to "some" newly created repeating rows(equipment, attacks, spells, nwp) using sheetworkers. I did this to help assist API interaction for David's complex ScriptCards macros.&nbsp;&nbsp;Some of these older repeating rows may not have had their old defaults set.&nbsp; I'll see if I can perhaps check and set with a one-time sheet version check. If you are seeing undefined for an attribute when trying to pull a value for API, either set the default yourself through API (preferred, but it might depend on the attribute and what you are wanting to do with it), changing the attribute on the sheet might also expose it if it gets handled by sheetworkers, or let me know and I should be able to include it when creating a new row and/or a sheet version update to check and set.
vÍnce said: If you are seeing undefined for an attribute when trying to pull a value for API, either set the default yourself through API (preferred, but it might depend on the attribute and what you are wanting to do with it),&nbsp; I've done that. You don't need to worry about doing anything with that. :-) Thanks Vince.
Rotto,&nbsp; I have started playing with the store in prep for a new campaign.&nbsp; &nbsp; Is there a way that I can only let the user see the Players Handbook Store and nothing else?&nbsp; &nbsp; I would like to be able to see everything as a GM, but for the players I only want them to see the Players Handbook Store or any store that I create. Also, is there an option to play with pricing?&nbsp; Not necessarily individual items, but to be able to add a markup.&nbsp; &nbsp;Maybe in some towns supplies are short and we want a 1.5x markup or something like that.&nbsp; (example, in the Dragonlance Campaign, there are towns such as Neraka that the prices are double or maybe even triple.)&nbsp; Would be a nice option if we could designate a store wide markup in pricing.&nbsp;&nbsp; Thank you very much, these projects you have been working on are great.
Tilt said: Rotto,&nbsp; I have started playing with the store in prep for a new campaign.&nbsp; &nbsp; Is there a way that I can only let the user see the Players Handbook Store and nothing else?&nbsp; &nbsp; I would like to be able to see everything as a GM, but for the players I only want them to see the Players Handbook Store or any store that I create. Also, is there an option to play with pricing?&nbsp; Not necessarily individual items, but to be able to add a markup.&nbsp; &nbsp;Maybe in some towns supplies are short and we want a 1.5x markup or something like that.&nbsp; (example, in the Dragonlance Campaign, there are towns such as Neraka that the prices are double or maybe even triple.)&nbsp; Would be a nice option if we could designate a store wide markup in pricing.&nbsp;&nbsp; Thank you very much, these projects you have been working on are great. It's a really great utility. FWIW, I went into the API and commented out non-PHB stuff and any other items I did not want under&nbsp; const ITEMS for example, early in the list, right after the first listing of Banded Mail,,there are these.&nbsp; /* { "key": "bronze_plate", "name": "Bronze Plate", "category": "armor", "price": "100 gp", "shopTypes": [ "baseline", "smith", "outfitter" ], "tags": [ "armor", "metal" ], "tier": "uncommon", "weight": 45.0, "ua": true }, { "key": "bronze_plate_x", "name": "Bronze Plate", "category": "armor", "price": "100 gp", "shopTypes": [ "smith", "outfitter", "baseline" ], "tags": [ "armor" ], "tier": "common", "weight": 45.0, "ua": false }, */ If you don't know how to comment out you prefix the blocks of code with a /* and then end the section you wanted out of there with */ which I've highlighted above. Best to copy ROTTO's code onto notepad or something and work with a copy.
Tilt.&nbsp; Players are able to see everything in the store is the way it's set up now. I would need to adjust it otherwise. There is a store feature where you can create stores and have a rotating stock. When you set up your store it does adjust the pricing based on the location. remote places things cost more etc. I don't have a the ability to set prices on the spot since this tool is desinged for players to use on their own.&nbsp; You could give them access to the command&nbsp;&nbsp; !shop-open baseline which is specific for the players handbook store
Hello, Has anyone written an api script that incorporates all the spells and monsters from OSRIC and allows&nbsp; them to be posted into the 1e sheet?
This character sheet mod has all the spells built into the character sheet from 1e.&nbsp; <a href="https://github.com/earmarkaudiology-png/1e-AD-D-Character-Sheet-Mod/tree/main" rel="nofollow">https://github.com/earmarkaudiology-png/1e-AD-D-Character-Sheet-Mod/tree/main</a> Here is the monster API....&nbsp; <a href="https://github.com/earmarkaudiology-png/MonsterManual" rel="nofollow">https://github.com/earmarkaudiology-png/MonsterManual</a>