#How to prevent apostrophes breaking text output & How to set properties via macro press
1 messages · Page 1 of 1 (latest)
For the set property i tried to do
[h: setProperty("Barbarian Rage", eval(RageRemaining))] and a few other variations, but i cant seem to get it to use/adjust the number properly. I basically want to take the EXISTING property value (within macro assigned to 'ragecount' for my own mental management but obviously can be pulled with getproperty) and have it set to reduce rage by 1 (obviously until it gets 0) every time its pressed. I'll then have another macro to reset it to the level appropriate value
Replace ' with '
That is the correct syntax for setProp. You don't need to eval everything tho
Weird...when i tried doing it before it didnt work...lemme try again
If I dont need to do eval, how can I set that up a bit better?
Also I presume if I dont want it going into negatives, I need to expand the code a bit so it wont go to 0 or have players make sure they keep the # in mind to avoid negatives?
also guessing theres no easier way than just replacing every ' in a contraction with "'"?
eval is for executing a string as a macro. You only do that if you're dynamically building that string or importing it from somewhere. You can just do RageRemaining=RageCount-1. Right after you get RageCount you could add
[r:assert(RageCount>0,"Out of Rage!")] - NOT TESTED
What does assert do?
Not aware of that one.
Appreciate the simplification of the eval code stuff. I mostly just hamstring shit as i hockney stuff together so 
https://wiki.rptools.info/index.php/assert
Bookmark the wiki, you'll be checking it a lot
i do try, its just everytime i go for help theres some new command ive never seen/heard/read lol
Cool; assert prevents negatives. Works for me!
Appreciate it.
And as I asked before; I presume theres no easier/cleaner way to use ' for contractions or other text output without using the & code stuff.
You could build your string with apostrophes and then use replace() to turn those into the HTML entity…
That sounds like needless overcomplication i'm guessing, so i'll stick with the & code 
Yeah, I’m sort of torn on it. When you get to that point, maybe have a UDF that does all such subs and call it whenever you’re going to be outputting a string.
That keeps all the subs in one place AND makes it easier to use.
Maybe tired fried brain but subs? as in substrings i presume? and UDF?
(for clarification i am NOT host nor DM of games so theres limits to what they will/will not OK. a lot of what ive learned/used here has been slow to be approved/done cause its functions/things they dont feel the need to use n stuff but i like learning n making macros so
)
You can create an html template in a macro. Just put in variable you're going to use with %{varName}. You can then use all the normal html syntax without worrying about breaking the parser. Then use my UDF text() to get the template and apply strformat to it.
The benefit of this is it doesn't go strait to chat allowing you to manipulate the text inside. For example, macro name page.html with your template. [H: output = strformat(text("page.html",tokenName))]