Thread Tools Display Modes
07-04-08, 10:34 AM   #1
Thijsd
A Murloc Raider
Join Date: Jul 2008
Posts: 6
Save variables to file?

Hi there,

Im making an addon, thats needs to put data into a file. This is becouse an application im making needs to acces IG data. (such as EXP, Mobs kileld, etc)

But how do i save data to a file, that can be readed by a application?



Hope you can help me.
  Reply With Quote
07-04-08, 10:38 AM   #2
Thijsd
A Murloc Raider
Join Date: Jul 2008
Posts: 6
Sorry, wrong forum Tnx for moving it
  Reply With Quote
07-04-08, 11:31 AM   #3
Shirik
Blasphemer!
Premium Member
WoWInterface Super Mod
AddOn Author - Click to view addons
Join Date: Mar 2007
Posts: 818
You have no direct access to file IO. The only "writing to file" you can do is through the SavedVariables system:

http://www.wowwiki.com/Saving_variab..._game_sessions

Some of the information in that article is a little out-of-date, but still valid.
__________________
たしかにひとつのじだいがおわるのお
ぼくはこのめでみたよ
だけどつぎがじぶんおばんだってことわ
しりたくなかったんだ
It's my turn next.

Shakespeare liked regexes too!
/(bb|[^b]{2})/
  Reply With Quote
07-04-08, 12:30 PM   #4
Thijsd
A Murloc Raider
Join Date: Jul 2008
Posts: 6
Originally Posted by Shirik View Post
You have no direct access to file IO. The only "writing to file" you can do is through the SavedVariables system:

http://www.wowwiki.com/Saving_variab..._game_sessions

Some of the information in that article is a little out-of-date, but still valid.
So i need to use:
## SavedVariables: Demo_test, Demo_foo

But how/where to declair this?
  Reply With Quote
07-04-08, 12:38 PM   #5
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
Featured
Join Date: Oct 2006
Posts: 10,860
In your TOC file. Upon reload ui or logout, whatever Demo_test and Demo_foo equal in your code at that time will be written to the saved variables file.
__________________
"You'd be surprised how many people violate this simple principle every day of their lives and try to fit square pegs into round holes, ignoring the clear reality that Things Are As They Are." -Benjamin Hoff, The Tao of Pooh

  Reply With Quote
07-04-08, 12:52 PM   #6
Thijsd
A Murloc Raider
Join Date: Jul 2008
Posts: 6
I have this in my toc file:

Code:
function Frame1_OnLoad()
     this:RegisterEvent("PLAYER_TARGET_CHANGED"); 
     this:RegisterEvent("SKILL_LINES_CHANGED");
     local skillRanktest = "test";
end


function Frame1_OnEvent(event)
     if event == "PLAYER_TARGET_CHANGED" then
	for skillIndex = 1, GetNumSkillLines() do
	  skillName, isHeader, isExpanded, skillRank, numTempPoints, skillModifier,
	    skillMaxRank, isAbandonable, stepCost, rankCost, minLevel, skillCostType,
	    skillDescription = GetSkillLineInfo(skillIndex)
	  if isHeader == nil then
	  	if skillName == "Skinning" then
	  		FontString1:SetText("Your skinning level is: " .. skillRank .. "!");
	  		FontString2:SetText("You can skinn level " .. math.floor(skillRank/5) .. " mobs");
	    	end
	  end
	end
     end
     if event == "SKILL_LINES_CHANGED" then
     	for skillIndex = 1, GetNumSkillLines() do
     	  skillName, isHeader, isExpanded, skillRank, numTempPoints, skillModifier,
     	    skillMaxRank, isAbandonable, stepCost, rankCost, minLevel, skillCostType,
     	    skillDescription = GetSkillLineInfo(skillIndex)
     	  if isHeader == nil then
     	  	if skillName == "Skinning" then
     	  		FontString1:SetText("Your skinning level is: " .. skillRank .. "!");
     	  		FontString2:SetText("You can skinn level " .. math.floor(skillRank/5) .. " mobs");
     	    	end
     	  end
	end
     end
end
But when i try to save " skillRank " I get 300, but it should be 256.
Where is this problem?
  Reply With Quote
07-04-08, 01:05 PM   #7
Thijsd
A Murloc Raider
Join Date: Jul 2008
Posts: 6
Tnx for all the help I solved it

Code:
function Frame1_OnEvent(event)
     if event == "PLAYER_TARGET_CHANGED" then
	for skillIndex = 1, GetNumSkillLines() do
	  skillName, isHeader, isExpanded, skillRank, numTempPoints, skillModifier,
	    skillMaxRank, isAbandonable, stepCost, rankCost, minLevel, skillCostType,
	    skillDescription = GetSkillLineInfo(skillIndex)
	  if isHeader == nil then
	  	if skillName == "Skinning" then
	  		FontString1:SetText("Your skinning level is: " .. skillRank .. "!");
	  		FontString2:SetText("You can skinn level " .. math.floor(skillRank/5) .. " mobs");
	  		skillRanktest = skillRank;
	    	end
	  end
	end
     end
     if event == "SKILL_LINES_CHANGED" then
     	for skillIndex = 1, GetNumSkillLines() do
     	  skillName, isHeader, isExpanded, skillRank, numTempPoints, skillModifier,
     	    skillMaxRank, isAbandonable, stepCost, rankCost, minLevel, skillCostType,
     	    skillDescription = GetSkillLineInfo(skillIndex)
     	  if isHeader == nil then
     	  	if skillName == "Skinning" then
     	  		FontString1:SetText("Your skinning level is: " .. skillRank .. "!");
     	  		FontString2:SetText("You can skinn level " .. math.floor(skillRank/5) .. " mobs");
     	  		skillRanktest = skillRank;
     	    	end
     	  end
	end
     end
end
  Reply With Quote

WoWInterface » Developer Discussions » General Authoring Discussion » Save variables to file?


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