Skip to content
This repository has been archived by the owner on Jul 12, 2022. It is now read-only.

Commit

Permalink
Update damage_report.lua
Browse files Browse the repository at this point in the history
Format for wrap.lua usage.
  • Loading branch information
herbmc authored Nov 20, 2020
1 parent 0fef88c commit 3319b8d
Showing 1 changed file with 32 additions and 19 deletions.
51 changes: 32 additions & 19 deletions damage_report.lua
Original file line number Diff line number Diff line change
@@ -1,23 +1,36 @@
unit.setTimer("dmgRpt", 1)
screen.activate()
script = {}

function update()
elements = core.getElementIdList()
local text = [[<html><head></head><body><table style="font-size:3em">]]
text = text .. [[<tr><th>ElementId</th><th>ElementType</th><th>ElementName</th><th>Remaining Hit Points</th><tr>]]
for i = 1, #elements do
elementInfo = database.getElement(core, elements[i])
if elementInfo['hitPoints'] < elementInfo['maxHitPoints'] then
text = text .. [[<tr>]]
text = text .. [[<td>]] .. elementInfo['id'] .. [[</td>]]
text = text .. [[<td>]] .. elementInfo['type'] .. [[</td>]]
text = text .. [[<td>]] .. elementInfo['name'] .. [[</td>]]
text = text .. [[<td align="right" style="font-family: monospace">]] .. string.format('%0.2f', elementInfo['hitPoints']/elementInfo['maxHitPoints']*100) .. [[%</td>]]
text = text .. [[</tr>]]
end
function script.onStart()
unit.setTimer("dmgRpt", 1)
screen.activate()

function update()
elements = core.getElementIdList()
local text = [[<html><head></head><body><table style="font-size:3em">]]
text = text .. [[<tr><th>ElementId</th><th>ElementType</th><th>ElementName</th><th>Remaining Hit Points</th><tr>]]
for i = 1, #elements do
elementInfo = database.getElement(core, elements[i])
if elementInfo['hitPoints'] < elementInfo['maxHitPoints'] then
text = text .. [[<tr>]]
text = text .. [[<td>]] .. elementInfo['id'] .. [[</td>]]
text = text .. [[<td>]] .. elementInfo['type'] .. [[</td>]]
text = text .. [[<td>]] .. elementInfo['name'] .. [[</td>]]
text = text .. [[<td align="right" style="font-family: monospace">]] .. string.format('%0.2f', elementInfo['hitPoints']/elementInfo['maxHitPoints']*100) .. [[%</td>]]
text = text .. [[</tr>]]
end
end
text = text .. [[</table></body></html>]]
screen.setHTML(text)
end
text = text .. [[</table></body></html>]]
screen.setHTML(text)
update()
end

function script.onStop()
screen.deactivate()
end

function script.onTick(dmgRpt)
update()
end

update()
script.onStart()

0 comments on commit 3319b8d

Please sign in to comment.