Hey guys,
I started making some simple addons just to get used to Lua and how it works with ESO.
Today I wanted to create a .txt-File and add some lines of text but I always get an UI Error saying "attempt to index a nil value" when it fires EVENT_POWER_UPDATE (eg. when I start running). The errormessage says its in the line 46
Lua Code:
local file = io.open('dpstest.txt', "w")
Here is the source code:
Lua Code:
DpsRace = {}
DpsRace.name = "DpsRace"
--
--
function DpsRace:OnAddOnLoad()
if addonName == DpsRace.name then
DpsRace:Initialize()
end
end
--
--
function DpsRace:Initialize()
d("test")
end
--
--
function DpsRace:GetSkill(eventCode, result, isError, abilityName, abilityGraphic, abilityActionSlotType, sourceName, sourceType, targetName, targetType, hitValue, powerType, damageType, log)
d(eventCode)
d(result)
d(isError)
d(abilityName)
d(abilityGraphic)
d(abilityActionSlotType)
d(sourceName)
d(sourceType)
d(targetName)
d(targetType)
d(hitValue)
d(hitValue)
d(powerType)
d(damageType)
d(log)
end
--
--
function DpsRace:CreateFile()
local file = io.open('dpstest.txt', "w")
file:write("Test")
file:close()
end
--
--
EVENT_MANAGER:RegisterForEvent(DpsRace.name, EVENT_ADD_ON_LOADED, DpsRace.OnAddOnLoad)
EVENT_MANAGER:RegisterForEvent(DpsRace.name, EVENT_COMBAT_EVENT, DpsRace.GetSkill)
EVENT_MANAGER:RegisterForEvent(DpsRace.name, EVENT_POWER_UPDATE, DpsRace.CreateFile)
Does anybody know what is wrong here?
Question No.2: Why isn't "test" displayed in the chat window when Initializing?
Thanks in advance for you help