Hi my name is Sk4lli,
i'm completely new to Lua scripting and thought ESO is a great game so i could give it a try.
in my First addon i would gather information about the Player Character and save it to the "Saved Variables" but there is already the problem because it won't save the variables, i don't know where i have made a mistake.
Code:
user:/AddOns/CharHarvester/Charharvester.lua:62: attempt to index a nil value stack traceback
user:/AddOns/CharHarvester/Charharvester.lua:62: in function 'CH.MotifKnown'
EsoUI/Ingame/SlashCommands/SlashCommands.lua:108: in function 'DoCommand'
EsoUI/Ingame/ChatSystem/ChatSystem.lua:1849: infunction 'ChatSystem:SubmitTextEntry'
EsoUI/Ingame/ChatSystem/ChatSystem.lua:2682: in Function 'TO_ChatTextEntry_Execute'
14406795741938050902:3: infunction '(main chunk)'
(tail call):?
- You are trying to get character information at the time when it is not available yet.
- It seems that you never call function CH.AssignMotifs() so the table CH.motifsList doesn't exists.
- Variable "addonName" in the CH.init function does not exist, name of argument you have defined is "addOnName".
- As katkat42 said, you have typo CH.defaults table name -> you have defined table "CH.defautls" and you are trying to use "CH.default".
Modified code:
Warning: Spoiler
Lua Code:
CH ={}
CH.name ="CharHarvester"
CH.version ="0.0A"
CH.defaults ={
data ={},
motifs ={},
}
CH.motifsList ={
[1]= ITEMSTYLE_RACIAL_HIGH_ELF, --Racial Motifs 1: The High Elves
[2]= ITEMSTYLE_RACIAL_DARK_ELF, --Racial Motifs 2: The Dark Elves
[3]= ITEMSTYLE_RACIAL_WOOD_ELF, --Racial Motifs 3: The Wood Elves
[4]= ITEMSTYLE_RACIAL_NORD, --Racial Motifs 4: The Nords
[5]= ITEMSTYLE_RACIAL_BRETON, --Racial Motifs 5: The Bretons
[6]= ITEMSTYLE_RACIAL_REDGUARD, --Racial Motifs 6: The Redguards
[7]= ITEMSTYLE_RACIAL_KHAJIIT, --Racial Motifs 7: The Khajiit
[8]= ITEMSTYLE_RACIAL_ORC, --Racial Motifs 8: The Orcs
[9]= ITEMSTYLE_RACIAL_ARGONIAN, --Racial Motifs 9: The Argonians
Lua language corner for loop control variable is implicitly local to the loop, you don't have to declare it. Actually your 'local m' is a different variable, shadowed by the 'for m' inside the loop. And to further simplify iterating an array-like table, use ipairs:
Lua Code:
-- used your names, but had to think twice, since conventionally 'i' is the index variable ;)