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

Commit

Permalink
Merge pull request #2 from herbmc/create-damage-report
Browse files Browse the repository at this point in the history
Create damage_report.lua
  • Loading branch information
herbmc authored Nov 20, 2020
2 parents 11572fc + ad7a189 commit b181ab5
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 1 deletion.
24 changes: 23 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ jobs:
run: |
lua5.3 -v
lua5.3 DU-Orbital-Hud/scripts/wrap.lua main/container_monitor.lua t1-t3-monitor.json --slots displayT1a:type=screen core displayT1b:type=screen displayT2a:type=screen displayT2b:type=screen displayT3a:type=screen displayT3b:type=screen
lua5.3 DU-Orbital-Hud/scripts/wrap.lua main/container_monitor.lua t4-t5-etc-monitor.json --slots displayT4a:type=screen core displayT4b:type=screen displayT5a:type=screen displayT5b:type=screen displayFuels:type=screen
lua5.3 DU-Orbital-Hud/scripts/wrap.lua main/damage_report.lua damage-report.json --slots core screen
- name: Create Release
id: create_release
uses: actions/create-release@v1
Expand Down Expand Up @@ -57,3 +59,23 @@ jobs:
asset_path: t1-t3-monitor.json
asset_name: t1-t3-monitor.json
asset_content_type: application/json

- name: Upload T4-T5-Etc PB as Release Asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above
asset_path: t4-t5-etc-monitor.json
asset_name: t4-t5-etc-monitor.json
asset_content_type: application/json

- name: Upload damage report PB as Release Asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above
asset_path: damage-report.json
asset_name: damage-report.json
asset_content_type: application/json
36 changes: 36 additions & 0 deletions damage_report.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
script = {}

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
update()
end

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

function script.onTick(dmgRpt)
update()
end

script.onStart()

0 comments on commit b181ab5

Please sign in to comment.