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

Commit

Permalink
Create damage_report.lua
Browse files Browse the repository at this point in the history
  • Loading branch information
herbmc authored Nov 20, 2020
1 parent 11572fc commit 0fef88c
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions damage_report.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
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

update()

0 comments on commit 0fef88c

Please sign in to comment.