#How to prevent apostrophes breaking text output & How to set properties via macro press

1 messages · Page 1 of 1 (latest)

quartz tide
#

Took a small break from writing my macros from ages ago. Trying to set up a friends token; apostrophes keep breaking lines and also I cant seem to set the macro to reduce the property value properly. I know im 'close' to doing it right but cant quite get there....

#

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

hasty talon
#

Replace ' with '
That is the correct syntax for setProp. You don't need to eval everything tho

quartz tide
#

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 "'"?

hasty talon
#

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

quartz tide
#

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 eonofaLUL

hasty talon
quartz tide
#

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.

quartz tide
dense sonnet
#

You could build your string with apostrophes and then use replace() to turn those into the HTML entity…

quartz tide
dense sonnet
#

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.

quartz tide
#

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 eonofaLUL )

true talon
#

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))]