Non-threaded

Forums » Advanced Editor Forum » Read Thread

Get help from the experts on variables, scripts, items, and other scary things.

Is this how it's supposed to be written?

7 years ago

NOTE: MERCIFUL = 50

I typed in:

%%MERCIFUL%%% Merciful/%%100 - MERCIFUL%%% Ruthless

Hoping I would get:

50% Merciful/50% Ruthless

But instead I got:

50%Merciful/0% Ruthless

 

Is there a way to subtract the value of a variable from a number and then display the result on a page?

Is this how it's supposed to be written?

7 years ago

If you're not using the rich text editor, you can use JS:

%%MERCIFUL%%% Merciful/<script>document.write(100 - %%MERCIFUL%%);</script>% Ruthless


Or, make a separate variable for ruthless and update it in a link script:

%RUTHLESS := 100 - %MERCIFUL

And:

%%MERCIFUL%%% Merciful/%%RUTHLESS%%% Ruthless


Alternatively, just use a page script instead:

$PAGETEXT := $PAGETEXT + %MERCIFUL + "% Merciful/" + (100 - %MERCIFUL) + "% Ruthless"

Is this how it's supposed to be written?

7 years ago

Ah, thanks!  You're a wizard at this stuff!

Is this how it's supposed to be written?

7 years ago
It's not going to do math right there on the page for you, the page has already loaded by the time you see it. If you need to alter variables put them in the link or page script.

Is this how it's supposed to be written?

7 years ago

Ah, makes sense why it wasn't working!

Is this how it's supposed to be written?

7 years ago
Indeed, the sequence of events is quite significant and can do some strange things when you don't fully understand exactly what's going on!