So I did a little work - but I have still problems with it...
(sorry for the self reply but I think editing my main would be confusing)
This is my main file
Lua Code:
-- a lebel must only be added if the item is a ingridient else it will conflict with research assistant
local function AddLabel(parentWindow)
local label = WINDOW_MANAGER:CreateControl(parentWindow:GetName() .. "_Tier", parentWindow, CT_LABEL)
label:SetDimensions(100,20)
label:SetAnchor(CENTER, parentWindow, CENTER, 150, -1)
label:SetFont("ZoFontGame")
label:SetText("Error")
label.itemArea = parentWindow:GetNamedChild("Tier")
label:SetHidden(true) -- has to be true
return label
end
-- Looks for an "^p" in the string and deletes it if it finds one
local function GetSingularName(name)
return string.gsub(name,"(\^p)","")
end
-- Adds a label to the inventory with the tier number and the color of the best to be produced provisioning item
local function AddTierToSlot(control)
local bagId = control.dataEntry.data.bagId
local slotIndex = control.dataEntry.data.slotIndex
local tierControl = control:GetNamedChild("_Tier")
local itemType = GetItemType(bagId, slotIndex)
if itemType == ITEMTYPE_INGREDIENT then
if not tierControl then
tierControl = AddLabel(control)
table.insert(controlsToWatch, tierControl)
end
local itemName = GetItemName(bagId, slotIndex)
itemName = GetSingularName(itemName)
-- if Ingredient is not in the DB to avoid an error
if not IngredientIsListed(language, itemName) then
return
end
local tier = GetIngredientTier(language, itemName) -- error
local color = GetProvisionColor(language, itemName)
tierControl:SetHidden(true) -- has to be true
if tier then
if color == "green" then
tierControl:SetText(tier)
tierControl:SetColor(0, 1, 0, 1)
elseif color == "blue" then
tierControl:SetText(tier)
tierControl:SetColor(0, 0, 1, 1)
elseif color == "violet" then
tierControl:SetText(tier)
tierControl:SetColor(1, 0, 1, 1)
elseif color == "gold" then
tierControl:SetText(tier)
tierControl:SetColor(1, 1, 0, 1)
else
tierControl:SetColor(0, 0, 0, 0)
end
tierControl:SetHidden(false)
end
end
end
it works with this one (to understand the code)
Lua Code:
-- will test if ingredient is already in the tabel
-- @param language english only at the moment
-- @param itemName name of item to be tested
-- @return false if not listed, true if it is
function IngredientIsListed(language, itemName)
if all_ingredients[language][itemName] == nil then
d("Please add "..itemName.." to the table at /matTIER/Ingredients.lua")
return false
end
return true
end
--
-- @param language english only at the moment
-- @param itemName name of item
-- @return gives back the tier
function GetIngredientTier(language, itemName)
local ingredient = all_ingredients[language][itemName]
return all_ingredients[language][itemName][3]
end
--
-- @param language english only at the moment
-- @param itemName name of item
-- @return gives back the color of the best provision item which can be crafted with it
function GetProvisionColor(language, itemName)
local ingredient = all_ingredients[language][itemName]
return all_ingredients[language][itemName][6]
end
And now it works
For interested ones:
Issues with the first code
#6 control:SetFont("ZoGameFont") has to be "ZoFontGame"
#9(new code) label.itemArea = parentWindow:GetNamedChild("Tier") is needed (for some reason) but i have no idea what it does Oo
#26 itemName = string.gsub(itemName,"s^p","") will delete also the "s" to the wanted "^p" but the singular name of grapes is still grapes^^
Buuut it doesn't work fine.
All the ingredients get the right number (tier) and the color but a lot of other items get numbers and colors too. They shouldn't because " if itemType == ITEMTYPE_INGREDIENT then" should make sure they keep untouched...
(Jazbay Grapes are right (they are for a tier 3 green reciepe) but the rest isn't)
I think the issue is with the inventory system of eso because the rows are not absolute like place 20/90 = id 20 but it is always the visual row.
If I see row 20-30 bagID 1 is row 20.
There is the issue I guess because my code may not delete the numbers after they are placed and with sliding all the numbers (if the row is not an ingredient) will still remain at the ID. Which could also lead to the "Double Same Name Children" Error i recieve^^
Soooo.... the only solution I can think of is to delete my table entry if the bagID is not an ingredient...
But how can I do that?
Or do you have an other solution?
Again: Sorry for my english I try but am a bit rusty (and never was really good with it to begin with
)
EDIT: An other issue is that my mod will overwrite the changes of the "research assistant" mod (maybe because I copied so much from him Oo) but I don't now why. It shouldn't^^
The table with the children of the inventory ([#8,8]) has only room for his or my mod...
EDIT: Ok I have solved everything - sometimes you just have to post a question to find a answer yourself^^ sorry
But at the same time I found an
AddOn which does the same but better :/
If anyone is interested in my mod I can post it but I will stop working on it (to test the AddOn from Wobin
)