-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add outputting info to file and info about ticks gained
- Now requires luafilesystem (lfs) - Fixed negative number display in friendlyNumber/friendlyTime
- Loading branch information
Showing
8 changed files
with
236 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
output | ||
|
||
# Created by https://www.gitignore.io/api/lua,linux,windows | ||
|
||
### Linux ### | ||
*~ | ||
|
||
# temporary files which can be created if a process still has a handle open of a deleted file | ||
.fuse_hidden* | ||
|
||
# KDE directory preferences | ||
.directory | ||
|
||
# Linux trash folder which might appear on any partition or disk | ||
.Trash-* | ||
|
||
# .nfs files are created when an open file is removed but is still being accessed | ||
.nfs* | ||
|
||
### Lua ### | ||
# Compiled Lua sources | ||
luac.out | ||
|
||
# luarocks build files | ||
*.src.rock | ||
*.zip | ||
*.tar.gz | ||
|
||
# Object files | ||
*.o | ||
*.os | ||
*.ko | ||
*.obj | ||
*.elf | ||
|
||
# Precompiled Headers | ||
*.gch | ||
*.pch | ||
|
||
# Libraries | ||
*.lib | ||
*.a | ||
*.la | ||
*.lo | ||
*.def | ||
*.exp | ||
|
||
# Shared objects (inc. Windows DLLs) | ||
*.dll | ||
*.so | ||
*.so.* | ||
*.dylib | ||
|
||
# Executables | ||
*.exe | ||
*.out | ||
*.app | ||
*.i*86 | ||
*.x86_64 | ||
*.hex | ||
|
||
|
||
### Windows ### | ||
# Windows thumbnail cache files | ||
Thumbs.db | ||
ehthumbs.db | ||
ehthumbs_vista.db | ||
|
||
# Folder config file | ||
Desktop.ini | ||
|
||
# Recycle Bin used on file shares | ||
$RECYCLE.BIN/ | ||
|
||
# Windows Installer files | ||
*.cab | ||
*.msi | ||
*.msm | ||
*.msp | ||
|
||
# Windows shortcuts | ||
*.lnk | ||
|
||
# End of https://www.gitignore.io/api/lua,linux,windows |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
local utils = require('d2info.utils') | ||
local lfs = require('lfs') | ||
local printf, friendlyNumber, friendlyTime, toFile = utils.printf, utils.friendlyNumber, utils.friendlyTime, utils.toFile | ||
|
||
local Output = {} | ||
Output.__index = Output | ||
|
||
function Output.new(outputDir) | ||
local self = setmetatable({}, Output) | ||
self.outputDir = outputDir or "output" | ||
if not lfs.attributes(self.outputDir) then | ||
assert(lfs.mkdir(self.outputDir)) | ||
end | ||
return self | ||
end | ||
|
||
function Output:toScreen(player, level, total, current, last) | ||
os.execute('cls') | ||
printf("%s\n", player) | ||
printf("Overall (real-time): %s xp/min", friendlyNumber(total:realTimeExpPerMin())) | ||
printf("Overall (game-time): %s xp/min", friendlyNumber(total:durationExpPerMin())) | ||
printf("Current game: %s xp/min", current and friendlyNumber(current:realTimeExpPerMin()) or "-") | ||
printf("Last game: %s xp/min", last and friendlyNumber(last:durationExpPerMin()) or "-") | ||
printf("\nEst time until level %d:", level+1) | ||
printf(" %s (using real-time xp/min)", friendlyTime(total:realTimeToNextLevel())) | ||
printf(" %s (using game-time xp/min)", friendlyTime(total:gameTimeToNextLevel())) | ||
printf(" %s (using current game's xp/min)", current and friendlyTime(current:gameTimeToNextLevel()) or "-") | ||
printf(" %s (using last game's xp/min)", last and friendlyTime(last:gameTimeToNextLevel()) or "-") | ||
printf("\nExp gained (overall): %s", friendlyNumber(total:expGained())) | ||
printf("Exp gained (current game): %s", current and friendlyNumber(current:expGained()) or "-") | ||
printf("Exp gained (last game): %s", last and friendlyNumber(last:expGained()) or "-") | ||
printf("\nTicks gained (overall): %0.1f", total:ticksGained()) | ||
printf("Ticks gained (current game): %0.1f", current and current:ticksGained() or 0) | ||
printf("Ticks gained (last game): %0.1f", last and last:ticksGained() or 0) | ||
end | ||
|
||
function Output:toFile(player, level, total, current, last) | ||
toFile(self.outputDir .. "/xpmin-realtime.txt", friendlyNumber(total:realTimeExpPerMin())) | ||
toFile(self.outputDir .. "/xpmin-gametime.txt", friendlyNumber(total:durationExpPerMin())) | ||
toFile(self.outputDir .. "/xpmin-currentgame.txt", current and friendlyNumber(current:realTimeExpPerMin()) or "-") | ||
toFile(self.outputDir .. "/xpmin-lastgame.txt", last and friendlyNumber(last:durationExpPerMin()) or "-") | ||
toFile(self.outputDir .. "/timetolevel-realtime.txt", friendlyTime(total:realTimeToNextLevel())) | ||
toFile(self.outputDir .. "/timetolevel-gametime.txt", friendlyTime(total:gameTimeToNextLevel())) | ||
toFile(self.outputDir .. "/timetolevel-currentgame.txt", current and friendlyTime(current:gameTimeToNextLevel()) or "-") | ||
toFile(self.outputDir .. "/timetolevel-lastgame.txt", last and friendlyTime(last:gameTimeToNextLevel()) or "-") | ||
toFile(self.outputDir .. "/ticksgained-overall.txt", string.format("%0.1f", total:ticksGained())) | ||
toFile(self.outputDir .. "/ticksgained-currentgame.txt", current and string.format("%0.1f", current:ticksGained()) or "-") | ||
toFile(self.outputDir .. "/ticksgained-lastgame.txt", last and string.format("%0.1f", last:ticksGained()) or "-") | ||
end | ||
|
||
return Output |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.