Post by imk on Dec 19, 2005 19:00:52 GMT -5
With the recent update of FFXI breaking the ExpWatch plugin for Windower I decided to create one in lua to work with Lunar.
The script and all newer versions can always be found at www.imk.cx/ffxi/ because I might not always update what I've posted here.
So far what I have working are TNL and XP/HR as well as a couple other things you'll see.
The code is below and it will follow the BSD license.
The script and all newer versions can always be found at www.imk.cx/ffxi/ because I might not always update what I've posted here.
So far what I have working are TNL and XP/HR as well as a couple other things you'll see.
The code is below and it will follow the BSD license.
-- LuaExpWatch
-- Copyright (C)2005 David Rudie
--
-- Version 0.2.0
--
-- To use this you must have the Lunar plugin for windower loaded
-- Once Lunar is loaded, load the script from the console as shown below:
-- .Lunar load expwatch.lua
--
-- For the resolutions mentioned below, just comment out the one you don't
-- need and un-comment the one you need.
Windower.script_SetAuthor("David Rudie")
Windower.script_SetContact("d.rudie@gmail.com")
Windower.script_SetName("LuaExpWatch")
Windower.script_SetVersion("0.2.0")
Windower.console_Write("LuaExpWatch v0.2.0 - Copyright(c)2005 David Rudie")
--Height = 600 -- 800 x 600
--Height = 768 -- 1024 x 768
--Height = 864 -- 1152 x 864
Height = 960 -- 1280 x 960
--Height = 1024 -- 1280 x 1024
--Height = 1200 -- 1600 x 1200 / 1920 x 1200
Font = "Arial"
FontSize = 10
-- -- -- -- -- Nothing below here should need changed. -- -- -- -- --
function SecondsToTime(secs)
time = {}
time.seconds = math.mod(secs, 60)
secs = math.floor(secs / 60)
time.minutes = math.mod(secs, 60)
secs = math.floor(secs / 60)
time.hours = math.mod(secs, 24)
secs = math.floor(secs / 24)
time.days = secs
return time
end
Height = Height - 16
TextBoxShadow = Graphics.text_CreateObject()
Graphics.text_SetColor(255, 0, 0, 0, TextBoxShadow)
Graphics.text_SetPosition(21, Height + 1, TextBoxShadow)
Graphics.text_SetFont(Font, FontSize, TextBoxShadow)
Graphics.text_SetBold(1, TextBoxShadow)
Graphics.text_SetVisibility(1, TextBoxShadow)
TextBox = Graphics.text_CreateObject()
Graphics.text_SetColor(255, 255, 100, 100, TextBox)
Graphics.text_SetPosition(20, Height, TextBox)
Graphics.text_SetFont(Font, FontSize, TextBox)
Graphics.text_SetBold(1, TextBox)
Graphics.text_SetVisibility(1, TextBox)
UpdateBox = Graphics.text_CreateObject()
Graphics.text_SetColor(255, 255, 255, 255, UpdateBox)
Graphics.text_SetPosition(15, Height, UpdateBox)
Graphics.text_SetFont(Font, FontSize, UpdateBox)
Graphics.text_SetBold(1, UpdateBox)
Graphics.text_SetVisibility(1, UpdateBox)
XPGain = 0
XPHR = 0
DiffXP = FFXI.player_GetCurrentXP()
DiffLevelXP = FFXI.player_GetLevelXP()
TTL = "Forever"
Seconds = "0"
while true do
Graphics.text_SetText("*", UpdateBox)
CurrentXP = FFXI.player_GetCurrentXP()
LevelXP = FFXI.player_GetLevelXP()
RemainingXP = FFXI.player_GetRemainingXP()
if CurrentXP ~= DiffXP then
if LevelXP > DiffLevelXP then
AddXP = (DiffLevelXP - DiffXP) + CurrentXP
XPGain = XPGain + AddXP
DiffLevelXP = LevelXP
else
AddXP = CurrentXP - DiffXP
XPGain = XPGain + AddXP
end
XPHR = XPHR + AddXP
DiffXP = CurrentXP
end
if XPHR > 0 then
XPHR = XPHR - (XPHR / 3600)
else
XPHR = XPGain - (XPGain / 3600)
end
if XPHR < 1 then
TTL = "Forever"
else
Seconds = CurrentXP / XPHR * 3600
Seconds = string.format("%i", Seconds)
TTL = SecondsToTime(Seconds)
TTL = table.concat({TTL.days, "d ", TTL.hours, "h ", TTL.minutes, "m ", TTL.seconds, "s"})
end
PercentXP = CurrentXP / LevelXP * 100
DispLine = string.format("EXP: %i/%i (%.2f%%) TNL: %i GAIN: %i EXP/HR: %i TTL: %s\r\n", CurrentXP, LevelXP, PercentXP, RemainingXP, XPGain, XPHR, TTL)
Graphics.text_SetText(DispLine, TextBoxShadow)
Graphics.text_SetText(DispLine, TextBox)
Graphics.text_SetText("", UpdateBox)
Windower.script_Sleep(1000)
end