Not crashing..
His Dad [03-11-15 - 06:52]
diff --git a/lua/GRID.lua b/lua/GRID.lua
index 976d2bd..e9747f1 100644
--- a/lua/GRID.lua
+++ b/lua/GRID.lua
@@ -217,6 +217,15 @@ function RT.GRID_Update(timestamp)
end
RT.Set_Shortest()
end
+function RT.Char_sort() -- Produce a sorted list for display
+ RT.CharsInOrder = {}
+ for k, _ in pairs(RT.SV.data.Craft) do
+ table.insert(RT.CharsInOrder,k)
+ end
+ if RT.SortFunction ~= nil then
+ table.sort(RT.CharsInOrder, function (a,b) return RT.SV.data.Craft[a].shortest < RT.SV.data.Craft[b].shortest end)
+ end
+end
-- move characters in grid
function RT.GRID_Sort()
@@ -229,3 +238,4 @@ function RT.GRID_Sort()
RT.UI.GRID_TLW:SetHeight(table.getn(RT.CharsInOrder) * panelheight)
end
+EVENT_MANAGER:RegisterForEvent(RT.name, EVENT_ADD_ON_LOADED, RT.Init)
diff --git a/lua/ResearchTimer.lua b/lua/ResearchTimer.lua
index 0f52ee0..158e255 100644
--- a/lua/ResearchTimer.lua
+++ b/lua/ResearchTimer.lua
@@ -9,6 +9,7 @@ RT = {
playername = "",
width = 100,
height = 80,
+ Init_done = false,
UI = {},
SV={}
}
@@ -62,15 +63,7 @@ function RT.Info_Research(craft_type,craft_id)
RT.SV.data.Craft[RT.playername][craft_id].Simu_craft = Simu_craft
end
-function RT.Char_sort() -- Produce a sorted list for display
- RT.CharsInOrder = {}
- for k, _ in pairs(RT.SV.data.Craft) do
- table.insert(RT.CharsInOrder,k)
- end
- if RT.SortFunction ~= nil then
- table.sort(RT.CharsInOrder, RT.SortFunction)
- end
-end
+
-- for each character, find the research completing soonest and set RT.SV.data.Craft[Char].shortest
function RT.Set_Shortest()
@@ -104,16 +97,10 @@ function RT.Research_started() -- Triggered by Event
end
-
-local function SortTimeA (a,b)
- return RT.SV.data.Craft[a].shortest < RT.SV.data.Craft[b].shortest
-end
-
function RT.Init(eventCode, addOnName)
if(addOnName == RT.name) then
- RT.Init_done = false
- RT.playername = GetUnitName("player")
+ RT.playername = GetUnitName("player")
-- SavedVariables
RT.SV.data = ZO_SavedVars:NewAccountWide(RT.name, 1, nil, nil )
@@ -187,5 +174,5 @@ function RT.CommandText_setup()
RT.toggleGRID()
end
-EVENT_MANAGER:RegisterForEvent(RT.name, EVENT_ADD_ON_LOADED, RT.Init)
+