-
Posted by zereges on Tue, 04 Oct 2011 21:35:10
Hi there, I am new to addon creating, I edited remaked 1addon, which shows raid readiness by counting their flasks, scrolls, etc which shows after pressing /command and I was wondering if I can make a "history" for it.
toc file:
## Interface: 30100 ## Version: 0.3 ; 3.3.5 Now ## Title: CheckForConsumables ## Author: Taneroth <EU Khadgar> ; Fixed by Zereges ## Notes: Checks if raid is using flasks / elixirs, scrolls food buffs. Also if raid is full possibly buffed. ## SavedVariables: ChechForConsumables CheckForConsumables.xml
xml file:
<Ui xmlns="http://www.blizzard.com/wow/ui/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.blizzard.com/wow/ui/ ..\FrameXML\UI.xsd"> <Script file="CheckForConsumables.lua"/> <Frame name="ConsumablesFrame" toplevel="true" frameStrata="LOW" enableMouse="true" parent="UIParent"> <Scripts> <OnLoad> CFC_OnLoad(); </OnLoad> </Scripts> </Frame> </Ui>
parts of lua file:
function CFC_OnLoad() SLASH_CFC1 = "/cfc"; SlashCmdList["CFC"] = CFC_RaidCheck; if (DEFAULT_CHAT_FRAME) then DEFAULT_CHAT_FRAME:AddMessage('CheckForConsumables: AddOn Loaded.'); end; end; function CFC_RaidCheck() ... blah blah blah ... SendChatMessage("Summary: About "..string.format("%.2f", RaidReadiness).."% raid is prepared.", "RAID"); CFC_SaveHistory(); function CFC_SaveHistory() HistoryFolder[] = { ["Time"] = {date("%H:%M:%S %m.%d.%Y")}, ["Basic Info"] = {"Zone: "..myZone..", "..aoizCount.."/"..GetNumRaidMembers()"."}, ["List of Members"] = {tmpEverybody}, ["Missing Flask or Elixir"] = {tmpConsumables}, ["Missing Scroll"] = {tmpScroll}, ["Missing Well Fed"] = {tmpWellFed}, ["Missing Rum"] = {tmpRum}, ["Raid Readiness"] = {string.format("%.2f", RaidReadiness)} } end;
myZone, aoizCount, tmp*, RaidReadiness are defined. Would this work? Id like addon to save this info to World of Warcraft\WTF\Account*\SavedVariables\CheckForConsumables.lua in format like
HistoryFolder1 = { ["Time"] = {date("%H:%M:%S %m.%d.%Y")}, ["Basic Info"] = {"Zone: Dalaran, 1/2."}, ["List of Members"] = {Name1, Name2}, ["Missing Flask or Elixir"] = {}, ["Missing Scroll"] = {Name1}, ["Missing Well Fed"] = {Name1}, ["Missing Rum"] = {Name2}, ["Raid Readiness"] = {50%} }
and after /cfc again it add new "line" with HistoryFolder2 and so on
-
Posted by jnwhiteh on Wed, 05 Oct 2011 10:08:04
You don't really ask any questions. Saved variables are just tables that are stored to disk in-between WoW sessions. If you want to store a history, you can do something like this:
- Add
## SavedVariables: CheckForConsumablesHistory
to your table of contents file. - Now, the contents of this global variable will be saved when the player reloads the user interface or disconnects. It will be reloaded at some stage when the player is logging back in.
For what you want, the best thing is probably to just add the new history entries like this:
function AddHistory(tbl) if not CheckForConsumablesHistory then CheckForConsumablesHistory = {} end table.insert(CheckForConsumables, tbl) end
Where
tbl
is just the data table you show at the end of your question (or whatever). Then, you can access hese history entries usngCheckForConsumablesHistory[1]
,CheckForConsumablesHistory[2]
or iterate over them by usingipairs(CheckForConsumablesHistory)
.If you have a more specific question, I can try to answer it.
- Add
-
Posted by zereges on Wed, 05 Oct 2011 14:05:56
Well, I added
## SavedVariables: CheckForConsumablesHistory
to my toc file.and I replaced my previous function with this:
funcion blah blah CFC_SaveHistory(tbl); end; function CFC_SaveHistory(tbl) local tbl = { ["Time"] = {date("%H:%M:%S %m.%d.%Y")}, ["Basic Info"] = {"Zone: "..myZone..", "..aoizCount.."/"..GetNumRaidMembers()"."}, ["List of Members"] = {tmpEverybody}, ["Missing Flask or Elixir"] = {tmpConsumables}, ["Missing Scroll"] = {tmpScroll}, ["Missing Well Fed"] = {tmpWellFed}, ["Missing Rum"] = {tmpRum}, ["Raid Readiness"] = {string.format("%.2f", RaidReadiness)} } if (not CheckForConsumablesHistory) then CheckForConsumablesHistory = {}; end; table.insert(CheckForConsumables, tbl) end;
but when i press /cfc it didnt make anything. What have I done wrong?
-
Posted by jnwhiteh on Wed, 05 Oct 2011 16:20:03
What do you want it to do? It'll add the entry to the table? What are you expecting to happen?
-
Posted by zereges on Wed, 05 Oct 2011 17:29:59
Normally it shows who has not flask/scroll/well fed and I want to add that people also to SavedVariables (like history) after I fire /command (it cyckles through raid members, and their buffs, shows who hasnot flask/scroll/well fed/.. and counts readiness of raid and I want to save history of it (like table), so I press command, it does its job and saves it to savedvariables as 1st save. Then I press it once more again, it again shows readiness, and again save itself to savedvariables as entry2 and so on.
Entry 1 Date: xx/xx/xxxx xx:xx:xx Players in raid: xxxx Flask missing: people swithout flask Raid readiness: blah blah
-
Posted by jnwhiteh on Thu, 06 Oct 2011 08:44:54
Then the code you've written should work. Saved variables are not saved until you reload the user interface or log out. They absolutely will not be written to disk immediately. I'm not entirely sure what the problem is.