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 .
×
Why do rogues wear leather armor? Because it’s made of hide. 🥷

New guy and API

Good evening, i'm a new guy with API and I don't have IT background...you see the guy. So i have copied and modified a script (yop can you believe it!lol) basically !enc-forest calling a random encounter. Me trying to be fancy would like to have it as a token for player to press have have it happen...so far, so good. Me wanted to be fancy was wondering can I use powercard to make it a nice visual....Problem is I don't know how to code it.. !power {{ --name|Random encouter and event  --bgcolor|#20124d --txcolor|#000000 --border|1px solid #000 --leftsub|Chance of encounter 30%  --rightsub|Undead emerge if roll is over 70% --api_Encounter|!enc-forest }} I know this is wrong but wondering if I don't have this backward and I should had something to my Script to have it more presentable..Help would be appreciated, from an older canadian :P
My only suggestion is since it sounds like you are new to api's.  Beware of api usage.  You can get swept up in the addictive nature of seeing them working by a pro and think they are so cool and awesome but to a novice user some of these api's are insanely prep heavy for very little payoff and/or sidegrades to things that are far more user friendly.  I won't name names for api's cause I don't want to offfend api scripters specifically but there are a ton of very popular api scripts that to me...are timesink pitfalls that give you nothing but a lil showmanship and hours of prep better spent on content creation.  Its a delicate balance act for VTT usage and DM prep.  Very easy to get lost in the flashy awe of api's.  
1644323152
David M.
Pro
API Scripter
Bruno, kudos for just diving in and trying your hand at script writing/modification! If your !enc-forest script already has some kind of chat output, then calling it from another script like powercards (or the recommended newer more powerful scriptcards) is not going to do anything for you, as there is no mechanism for these parent scripts to receive any info from your custom script in order to process that info and "pretty it up". So, to change the presentation of your !enc-forest script you would need to make changes from within your script. Just a note: if you don't have a background in html/css, then this can be a bit of a process! If that is the case (like it is/was for me), then I would poke around some existing scripts to see if there is anything that has a similar look to what you are trying to accomplish, see how they went about creating that output, and use that as a starting point.  If that is too involved, then another option (depending on how complex your script's logic is) is to use something like scriptcards to replace your !enc-forest script completely. For example, something like rolling a percentile die and using that result to dynamically generate a roll on a specific rollable table and customize the output is easily within the capabilities of that script. It is also easy to modify later and wouldn't require re-compiling every time it is changed. If you decide to go that route, there are plenty of folks on the main scriptcards thread that can help you out.   
Good morning, and thank you for sound advice from you two! I know rollable table and use them in the past, like small macros, was just aiming to further the skills,lol. I'm not a html/css guy, i basically took a script modified what i could and ran with it,lol. So i guess it is the way to go searchin for a script that actually give me a result i like better, Again thank you both and the older canadian will move forward...lol
1644336573
David M.
Pro
API Scripter
Just to show you a couple of scriptcard options that wouldn't require altering api scripts: (1) Simple scriptcard that calls one of two rollable tables based on a percentile roll (plus a No Encounter option). This example does not expand the inline roll results (e.g. 1d4+2 shadows), though you could perform similar logic that instead dynamically created a roll on the RecursiveTables script and used that scripts output. !script {{ --#title|Random encounter and event --#leftsub|Chance of encounter 30% --#rightsub|Undead emerge if roll is over 70% --=roll|1d100 --+Encounter Roll|[$roll] --?[$roll] -lt 30|[ --+No Encounter|Everyone is safe...for now! --X| End Macro --]| --?[$roll] -gt 70|[ --=UndeadTableRoll|[T#UndeadEncounters] --+Undead Encounter!|[$UndeadTableRoll.tableEntryText] --X| End Macro --]|[ --=BeastTableRoll|[T#BeastEncounters] --+Beast Encounter!|[$BeastTableRoll.tableEntryText] --X| End Macro --]| }} Output: (2) Not using rollable tables but instead building the logic into the scriptcard itself. Simple example below only has three creature options each for Undead or Beast Encounters (I also used different numbers compared to the first script as I was typing in a stream of consciousness way haha). This option has the advantage of calculating the number of creatures, but is considerably more difficult to maintain than the rollable table option. This is just to show you the kind of flexibility scriptcards offers. See DM Eddie's comments on DM prep time vs payoff, something that will obviously vary for each individual. For example, I rarely use truly random encounters in my games, so I don't spend much time with this stuff. Instead, I have one or two encounters in mind and just roll for whether they happen or not. So, YMMV. !script {{ --#title|Random encounter and event --#leftsub|Chance of encounter 30% --#rightsub|Undead emerge if roll is over 70% --=roll|1d100 --+Encounter Roll|[$roll] --?[$roll] -lt 30|[ --+No Encounter|Everyone is safe...for now! --X| End Macro --]| --?[$roll] -gt 70|>UndeadEncounter|>BeastEncounter --X| End Macro --:Functions| --:UndeadEncounter| --=encounterRoll|1d20 --?[$encounterRoll] -le 4|[ --=numCreatures|1d4 --+Undead Encounter!|[$numCreatures] Wights --]| --?[$encounterRoll] -gt 4 -and [$encounterRoll] -le 10|[ --=numCreatures|3d4+3 --+Undead Encounter!|[$numCreatures] Skeletons --]| --?[$encounterRoll] -gt 10|[ --=numCreatures|2d6 --+Undead Encounter!|[$numCreatures] Ghouls --]| --:BeastEncounter| --=encounterRoll|1d20 --?[$encounterRoll] -le 4|[ --=numCreatures|1d4 --+Beast Encounter!|[$numCreatures] Brown Bears --]| --?[$encounterRoll] -gt 4 -and [$encounterRoll] -le 10|[ --=numCreatures|3d4+3 --+Beast Encounter!|[$numCreatures] Wolves --]| --?[$encounterRoll] -gt 10|[ --=numCreatures|2d6 --+Beast Encounter!|[$numCreatures] Black Bears --]| --<| }} Output:
1644384251

Edited 1644386006
Victor B.
Pro
Sheet Author
API Scripter
So many people ask this every few months or so The mandatory: 1) Token Mod for API related changes to a token 2) CharSetAttr for changes to character sheet Read both and understand them.  You can launch from macro or other areas Optional Pretty much everything else.  I use GroupInit (which rolls initiative for selected tokens and adds to turnorder) Combat Master (which tracks initiative...when starting up combat...use with group init if adding more tokens into combat,.conditions and condition durations, launches API calls to adjust token or char sheet based on condition...plus more) GroupCheck  which auto checks saves vs. DC vs. damage and Apply Damage (which isn't committed to repo for some strange region but then automatically applies damage...makes the fireballs easy to manage...ask for the Apply Damage code) TokenCondition which enables things like mounts or torches to be applied to tokens and then the mount or light moves with the character (and the dynamic lights moves with the character Roll20AM because I like UI menus in chat to control launching music libTokenMarkers to support custom icons sets Aura/Tint colors to show where the NPC is at in terms of damage (shows green/yellow/red based on damage and the players don't have to constantly ask) 5th Edition OGL (companion script to Roll20 5e OGL to support things like ammo tracking etc.) Also I'm considered "light" with API.  People here LOVE macros for everything, and more everything.  I like simple.  A UI to manage something or an API that allows for simple behavior.  Select and click...nothing more.  
1644415378

Edited 1644417908
Thanks David, that awesome!! Let me play with it and let you know if i have more questions? is That ok? Victor thank you for you help! Now I have a question...Do I need to download another script for that ? sign: the older canadian
1644415823
David M.
Pro
API Scripter
Sure, feel free to PM me if you have specific questions