@inc from a variable

Padrinos
With the help of other posts, I figured out how to have something give a random number based on a set range, but is there is way to have that random number added to something? As in @inc reputation 2
This is what I have, but cant get it to add up. Thanks for any help.

var randomnumber = function rng(min, max) {
return Math.floor(Math.random() * (max - min) + min);
}

set ("earnRep", randomnumber(2,6));

<u>Reputation increases by {earnRep}</u><br>
@inc reputation {earnRep}<br>
<b>Reputation = {reputation}</b><br>

Alex
You would need to use JavaScript for this, as @inc only handles numbers.

Try this after your code for setting earnRep:


set ("reputation", get("reputation") + get("earnRep"));

Padrinos
Thanks Alex, that worked as far as adding the random number to the reputation, but the @inc shows.

Here is what I typed:
[[rep]]:
var randomnumber = function rng(min, max) {
return Math.floor(Math.random() * (max - min) + min);
}

set ("earnRep", randomnumber(2,6));
set ("reputation", get("reputation") + get("earnRep"));

<u>Reputation increases by {earnRep}</u><br>
@inc reputation {earnRep}<br>
<b>Reputation = {reputation}</b><br>

Here is how it displayed:
Reputation increases by 4
@inc reputation 4
Reputation = 17

So everything added correctly, just displays the @inc reputation #

Alex
You don't need the @inc line in there any more, you're increasing the reputation score using JavaScript now.

Padrinos
Alex, you are awesome. Thank you very much

This topic is now closed. Topics are closed after 180 days of inactivity.

Support

Forums