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

Mathematical Sequence

1664465723
Wizi
Pro
Hello friends,  I wish to use a function for my xp_max for every lvl. this function rely on a simple mathematic sequence whitch is :  Lvl 1, you need 100 xp to lvl up  Lvl 2 you need 200xp more, so it become 300 etc... From what I understand, it can be done using API or Sheet Worker, but I'm not very good at it and my few attemps to use it for setting the value of an attribute were uneffective. This is why I came to you guys to see if :  1- is there a simpler way to do it without using sheet worker  2- if not maybe give a proper example of how I should set up this function for it to be my xp_max Sorry if I'm asking a stupid question, and thank you in advance for your help. If I can do anything more to clarify my issue, please let me know
1664465756
Wizi
Pro
1664469857
timmaugh
Pro
API Scripter
Can you not start with the current value of the xp_max , and just add the multiplicative output of the new level * 100? All sheet retrieval is done at the time a command is issued, so you can get the level of a character and add 1, and then use that in various places in a ChatSetAttr call. If your character level attribute were named char_lvl , and if xp_max were an attribute where you were using the current value (as opposed to referring to the max value of the xp attribute) this might look like: !setattr --sel --char_lvl|[[@{selected|char_lvl}+1]] --xp_max|[[@{selected|xp_max} + ((@{selected|char_lvl}+1) * 100)]] That would basically be a "LevelUp" macro. I just tried that in my game, and it works.
1664471312
Wizi
Pro
Yeah that's what I'm using right now, but it seemed more convinient for me if I had this mathematical sequence. That way I don't have to do it again every lvl up.  But if it's the only solution I'll stick to it x) thank you 
1664472850
timmaugh
Pro
API Scripter
Well, I think you could make the attribute a computed attribute, and have the character sheet take care of it for you -- if you have access to (or are, yourself, building) the sheet. Little out of my wheelhouse on that one. The thing about the API is you'll have to trigger it (like I demonstrated with the CSA call). The sheet should be able to perform the math for you, but you might want to post in the Character Sheets forum to catch the eye of the people with more experience.
1664532999
Wizi
Pro
Sure thank you !