diff --git a/lua/CORE.lua b/lua/CORE.lua
index 0a3737f..4c4ef21 100644
--- a/lua/CORE.lua
+++ b/lua/CORE.lua
@@ -3,7 +3,6 @@
function CRT.Collect_Data()
- CRT.SV.data.Craft[CRT.playername].shortest = 99999999 -- for this player find next due.
CRT.Info_Research(CRAFTING_TYPE_BLACKSMITHING, 0)
CRT.Info_Research(CRAFTING_TYPE_CLOTHIER, 1)
CRT.Info_Research(CRAFTING_TYPE_WOODWORKING, 2)
@@ -15,24 +14,23 @@ function CRT.Info_Research(craft_type,id_craft)
local ResearchLines, ResearchTrait
local MaxResearch = GetMaxSimultaneousSmithingResearch(craft_type)
local nbtype = GetNumSmithingResearchLines(craft_type) --Nombre de item craftable pour un craft(ex couture: jambe/robe/ect)
-
+
CRT.SV.data.Craft[CRT.playername][id_craft] = {}
for ResearchLines = 1, nbtype, 1 do
local item_name, item_icon, numTraits, timeRequiredForNextResearchSecs = GetSmithingResearchLineInfo(craft_type, ResearchLines)
for ResearchTrait = 1, numTraits, 1 do
- local duration, timeRemaining = GetSmithingResearchLineTraitTimes(craft_type, ResearchLines, ResearchTrait)
-
+ local duration, timeRemaining = GetSmithingResearchLineTraitTimes(craft_type, ResearchLines, ResearchTrait)
+
if (duration ~= nil and timeRemaining ~= nil) then
-
Simu_craft = Simu_craft + 1
-
-
+
+
local traitType, trait_description, _ = GetSmithingResearchLineTraitInfo(craft_type,ResearchLines,ResearchTrait)
local _, trait_name, trait_icon, _, _, _, _ = GetSmithingTraitItemInfo(traitType+1)
-
-
+
+
CRT.SV.data.Craft[CRT.playername][id_craft][Simu_craft] = {}
CRT.SV.data.Craft[CRT.playername][id_craft][Simu_craft]["PlayerName"] = CRT.playername
CRT.SV.data.Craft[CRT.playername][id_craft][Simu_craft]["Alert"] = true
@@ -42,36 +40,49 @@ function CRT.Info_Research(craft_type,id_craft)
CRT.SV.data.Craft[CRT.playername][id_craft][Simu_craft]["Trait_name"] = trait_name
CRT.SV.data.Craft[CRT.playername][id_craft][Simu_craft]["Trait_icon"] = trait_icon
CRT.SV.data.Craft[CRT.playername][id_craft][Simu_craft]["Trait_description"] = trait_description
-
- if CRT.SV.data.Craft[CRT.playername].shortest > timeRemaining
- then CRT.SV.data.Craft[CRT.playername].shortest = timeRemaining
- end
- -- d("Type de craft :"..id_craft.." nom de l'item :"..name.." temps restant :"..temp_timer[Simu_craft])
end
end
end
CRT.SV.data.Craft[CRT.playername][id_craft]["MaxResearch"] = MaxResearch
CRT.SV.data.Craft[CRT.playername][id_craft]["Simu_craft"] = Simu_craft
-end
+end
function CRT.Char_sort() -- Produce a sorted list for display
CRT.CharsInOrder = {}
- for k, _ in pairs(CRT.SV.data.Craft) do
+ for k, _ in pairs(CRT.SV.data.Craft) do
table.insert(CRT.CharsInOrder,k)
- end
+ end
if CRT.SortFunction ~= nil then
table.sort(CRT.CharsInOrder, CRT.SortFunction)
end
end
+
+-- for each character, find the research completing soonest and set CRT.SV.data.Craft[Char].shortest
+function CRT.Set_Shortest()
+ local char,craft,shortest, remaining,v
+ for char,_ in pairs (CRT.SV.data.Craft) do
+
+ shortest = 9999999999
+ for craft =0,2, 1 do
+ for _,v in pairs (CRT.SV.data.Craft[char][craft]["Simu_craft"])
+ remaining = v["EndTimeStamp"] - GetTimeStamp()
+ if shortest > remaining
+ then shortest = remaining
+ end
+ end
+ end
+ CRT.SV.data.Craft[char].shortest = shortest
+end
+
function CRT.Research_started()
-
-- erase all data for this character
CRT.SV.data.Craft[CRT.playername] = {}
-- Collect new data
- CRT.Collect_Data()
-
+ CRT.Collect_Data()
+
if (CRT.UI.GRID_WD[CRT.playername] == nil) then
CRT.GRID_Create_Character(CRT.playername)
end
- -- CRT.Char_sort()
-end
\ No newline at end of file
+ CRT.Set_Shortest()
+end
+
diff --git a/lua/GRID.lua b/lua/GRID.lua
index c570c51..38edc85 100644
--- a/lua/GRID.lua
+++ b/lua/GRID.lua
@@ -241,6 +241,7 @@ function CRT.GRID_Update(timestamp)
end
end
end
+ CRT.Set_Shortest()
end
-- move characters in grid