Hello Guys.
I'm making a mini-rpg, and trying to make a system with some points that the players can distribute.
I'd like to have buttons with + and - that changed the values, (replacing them), and that also stopped working once the player reached 0 points to distribute.
Here's my code:
There is anyway to make this thing into a JavaScript macro, so I don't have to type all this stuff over and over just so the player can change his stats clicking?
Like <<distplus $points $player.st "#st" "#points">> ?
Thanks for the help!
I'm making a mini-rpg, and trying to make a system with some points that the players can distribute.
I'd like to have buttons with + and - that changed the values, (replacing them), and that also stopped working once the player reached 0 points to distribute.
Here's my code:
<<nobr>><<set $player = { "name" : "Rodrigo", "st" : 1, "ag" : 1, "en" : 1, "in" : 1, "ch" : 1, "uk" : 1, "hptotal" : 10, "hpnow" : 9, "gold" : 0 }>> <<set $points = 6>> <<set $pointsmax = 6>> <</nobr>>''$player.name'' Points to Distribute: <span id="points">$points</span> Strength: <span id = "st">$player.st</span><<nobr>> <<button "+">> <<if $player.st == 5>> <<elseif $points == 0>> <</elseif>> <<else>> <<set $player.st = $player.st + 1 >> <<set $points = $points - 1>> <<replace "#st">> <<print $player.st>> <</replace>> <<replace "#points">> <<print $points>> <</replace>> <</else> <</if>> <</button>> <<button "-">> <<if $player.st == 1>> <<elseif $points == $pointsmax>> <</elseif>> <<else>> <<set $player.st = $player.st -1 >> <<set $points = $points + 1>> <<replace "#st">> <<print $player.st>> <</replace>> <<replace "#points">> <<print $points>> <</replace>> <</if>> <</button>> </span>\ <</nobr>>
There is anyway to make this thing into a JavaScript macro, so I don't have to type all this stuff over and over just so the player can change his stats clicking?
Like <<distplus $points $player.st "#st" "#points">> ?
Thanks for the help!