Thread Tools Display Modes
08/24/14, 02:22 PM   #1
brekal
Guest
Posts: n/a
Create txt-file error

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:
  1. local file = io.open('dpstest.txt', "w")

Here is the source code:

Lua Code:
  1. DpsRace = {}
  2. DpsRace.name = "DpsRace"
  3.  
  4. --
  5. --
  6.  
  7. function DpsRace:OnAddOnLoad()
  8.     if addonName == DpsRace.name then
  9.         DpsRace:Initialize()
  10.     end
  11. end
  12.  
  13. --
  14. --
  15.  
  16. function DpsRace:Initialize()
  17.  d("test")
  18. end
  19.  
  20. --
  21. --
  22.  
  23. function DpsRace:GetSkill(eventCode, result, isError, abilityName, abilityGraphic, abilityActionSlotType, sourceName, sourceType, targetName, targetType, hitValue, powerType, damageType, log)
  24.     d(eventCode)
  25.     d(result)
  26.     d(isError)
  27.     d(abilityName)
  28.     d(abilityGraphic)
  29.     d(abilityActionSlotType)
  30.     d(sourceName)
  31.     d(sourceType)
  32.     d(targetName)
  33.     d(targetType)
  34.     d(hitValue)
  35.     d(hitValue)
  36.     d(powerType)
  37.     d(damageType)
  38.     d(log)
  39. end
  40.  
  41.  
  42. --
  43. --
  44.  
  45. function DpsRace:CreateFile()
  46.     local file = io.open('dpstest.txt', "w")
  47.     file:write("Test")
  48.     file:close()
  49.  
  50. end
  51.  
  52. --
  53. --
  54.  
  55.  
  56.  
  57. EVENT_MANAGER:RegisterForEvent(DpsRace.name, EVENT_ADD_ON_LOADED, DpsRace.OnAddOnLoad)
  58. EVENT_MANAGER:RegisterForEvent(DpsRace.name, EVENT_COMBAT_EVENT, DpsRace.GetSkill)
  59. 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
  Reply With Quote
08/24/14, 02:58 PM   #2
Garkin
 
Garkin's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 832
A1: ESO does not support io library, you can't read from or write to disk.
EDIT: Actually the only way how to read/write to disk are saved variables defined in the addon manifest (.txt file). And may be I can mention chat log ( SetChatLogEnabled(true) ).

A2: Because chat system is initialized later then your addon is loaded. If you want to display "test" message, call d("test") from the EVENT_PLAYER_ACTIVATED handler.

Last edited by Garkin : 08/24/14 at 03:03 PM.
  Reply With Quote
08/24/14, 03:09 PM   #3
brekal
Guest
Posts: n/a
thank you very much for your fast and precise response. :-)
  Reply With Quote

ESOUI » Developer Discussions » Lua/XML Help » Create txt-file error


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off