Tweak dice code further. #1218
Also use `data` instead of `textContent` as it performs faster.
This commit is contained in:
parent
8c95fe1995
commit
2cbf3d909d
@ -5,12 +5,7 @@ Dice =
|
||||
name: 'Show Dice Roll'
|
||||
cb: @node
|
||||
node: ->
|
||||
return if @isClone or not dicestats = @info.email?.match /dice\+(\d+)d(\d+)/
|
||||
return if @isClone or not dicestats = @info.email?.match /dice[+\s](\d+)d(\d+)/
|
||||
# Use the text node directly, as the <b> has two <br>.
|
||||
roll = $('b', @nodes.comment).firstChild
|
||||
# Stop here if it looks like this:
|
||||
# Rolled 44
|
||||
# and not this:
|
||||
# Rolled 9, 8, 10, 3, 5 = 35
|
||||
return unless rollResults = roll.textContent.match /^Rolled (\d+)$/
|
||||
roll.textContent = "Rolled #{dicestats[1]}d#{dicestats[2]} and got #{rollResults[1]}"
|
||||
roll.data = "Rolled #{dicestats[1]}d#{dicestats[2]} and got #{roll.data.slice 7}"
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user