Thread Tools Display Modes
05-30-10, 10:52 PM   #1
clowcadia
A Chromatic Dragonspawn
Join Date: Apr 2010
Posts: 186
Block too big?

i get an error, every time that i log in on a new day
do to one function that i will highlight, that created too much tables and gives me an erros of block too big
any ideas why

Code:
-- Author      : Andrew
-- Create Date : 5/28/2010 8:26:28 PM
local addonLoadedCount = 0;
local sessionCount = 0;
local currentDate = date("%m/%d/%y");
local currentTime = date("%H:%M:%S");
local sessionValue; 

local function startSessionInfo()
sessionDate = currentDate

sessionInfo = { [sessionDate] = { sessionCount } }

end

local function newDaySessionInfo()
sessionDate = currentDate

tinsert( sessionInfo, { [sessionDate] = { sessionCount } } )

end

local function onEvent(self,event,...)
----------------------------------------------
 if ( event == "ADDON_LOADED" ) then
addonLoadedCount = addonLoadedCount + 1;
sessionCount=0;
currentDate = date("%m/%d/%y");

  if ( addonLoadedCount == 3 ) then
  print("GVLT Loaded")
   if ( sessionInfo == nil ) then
   startSessionInfo();
   print("New Log File Begun")
   else
    for key,value in pairs(sessionInfo) do
     if ( key == currentDate ) then
     print("Current Day Log Loaded")
     else
     newDaySessionInfo()
     print("New Day Log Begun")
     end
    end
   end   
  end
   
 end
   
 ---------------------------------------------
 if ( event == "GUILDBANKFRAME_OPENED" ) then 
  sessionCount = sessionCount + 1;
  print(sessionCount) 
  
 end
 
 -----------------------------------------------

end

local evFrame = CreateFrame("Frame","evFrame",UIParent);
evFrame:SetScript( "OnEvent", onEvent );
evFrame:RegisterEvent( "ADDON_LOADED" );
evFrame:RegisterEvent( "GUILDBANKFRAME_OPENED" );
evFrame:RegisterEvent( "GUILDBANKFRAME_CLOSED" );
  Reply With Quote
05-30-10, 11:01 PM   #2
Xrystal
nUI Maintainer
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 5,929
Your problem is that you're doing too many { } entries. Each pair of those braces creates a table and it looks like it is creating tables within tables within tables.

Your best bet is to think up an example of what you want it to look like in the save table and then fit the data into that.

EG.

Code:
SessionData = {
    [Date1] = { ValuesForDate1 },
    [Date2] = { ValuesForDate2 },
    [Date3] = { ValuesForDate3 },
    [Date4] = { ValuesForDate4 },
    [Date5] = { ValuesForDate5 },
    [Date6] = { ValuesForDate6 },
}
This is a 2 deep table .. but looking at what you are wanting to store in there try this and see if this stores the info you want without the errors.

Code:
local function startSessionInfo()
   sessionDate = currentDate
   sessionInfo = { [sessionDate] = sessionCount }
end
Code:
local function newDaySessionInfo()
   sessionDate = currentDate
   tinsert( sessionInfo, { [sessionDate] = sessionCount } )
end
__________________


Characters:
Gwynedda - 70 - Demon Warlock
Galaviel - 65 - Resto Druid
Gamaliel - 61 - Disc Priest
Gwynytha - 60 - Survival Hunter
Lienae - 60 - Resto Shaman
Plus several others below level 60

Info Panel IDs : http://www.wowinterface.com/forums/s...818#post136818
  Reply With Quote
05-30-10, 11:13 PM   #3
clowcadia
A Chromatic Dragonspawn
Join Date: Apr 2010
Posts: 186
made the changes you have advised. and yet i am running in the same problem
but now i have been reloading, so it should mean it should compare the dates, and yet still says "creating a new date log"(dont remember exact saying in it) and it multiplies the tables
  Reply With Quote
05-30-10, 11:26 PM   #4
clowcadia
A Chromatic Dragonspawn
Join Date: Apr 2010
Posts: 186
ok it works properly now thanks crystal
  Reply With Quote
05-30-10, 11:29 PM   #5
clowcadia
A Chromatic Dragonspawn
Join Date: Apr 2010
Posts: 186
nvm still the same probleme
  Reply With Quote
05-30-10, 11:30 PM   #6
clowcadia
A Chromatic Dragonspawn
Join Date: Apr 2010
Posts: 186
double checking code, is a must .. feel dumb
  Reply With Quote
05-30-10, 11:36 PM   #7
clowcadia
A Chromatic Dragonspawn
Join Date: Apr 2010
Posts: 186
ok i am not that dumb after all

i tested it with fresh file, and it madea new one as it should, then i changed the date, it made a new one no problme, but once i left it alone to see if it recognises it still begun to create thousands more

the code is identical to yours

Code:
local function startSessionInfo()
sessionDate = currentDate

sessionInfo = { [sessionDate] = sessionCount }

end

local function newDaySessionInfo()
sessionDate = currentDate

tinsert( sessionInfo, { [sessionDate] = sessionCount } )

end
  Reply With Quote
05-30-10, 11:49 PM   #8
Starinnia
Ninja Code Monkey
AddOn Author - Click to view addons
Join Date: Apr 2007
Posts: 84
Your call to table.insert means that your pairs loop is iterating over integer keys not the date keys. So you are comparing the current date to 1, 2, 3, etc.

You probably want something like:
Code:
local function newDaySessionInfo()
    sessionDate = currentDate

    sessionInfo[sessionDate] = sessionCount

end
Given the current code I imagine your table looks something like:
Code:
sessionInfo = {
    ["05/31/2010"] = 5,
    [1] = {
        ["06/01/2010"] = 2,
    },
    [2] = {
        ["06/02/2010"] = 2,
    },
}
  Reply With Quote
05-30-10, 11:52 PM   #9
clowcadia
A Chromatic Dragonspawn
Join Date: Apr 2010
Posts: 186
hmm intresting, i worked with the table[value] before but when i came to pairs function, it was said that pairs works to a limit. where it does not work with subtables such as table[value]
  Reply With Quote
05-31-10, 12:34 AM   #10
Torhal
A Pyroguard Emberseer
 
Torhal's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2008
Posts: 1,196
The pairs() function works on a data-pair of key/value.

A value can itself be a table.

Example:

Code:
for name, data in pairs(information) do
        for month, week in pairs(data) do
                -- Your code here.
        end
end
This iterates over the key/value pairs in the table named "information", where the keys are strings which represent names and the values are tables - it then iterates over the key/value pairs of the value tables, where the key represents a month and its value represents a week.

Note that this is in no way a real design - I simply chose variable names based on what you're currently dealing with; time.
__________________
Whenever someone says "pls" because it's shorter than "please", I say "no" because it's shorter than "yes".

Author of NPCScan and many other AddOns.
  Reply With Quote
05-31-10, 01:05 AM   #11
clowcadia
A Chromatic Dragonspawn
Join Date: Apr 2010
Posts: 186
hmm ok very informative Torhal.
thank you very much
now i got another problem. i got a second subtable made for session count. but that resets every time i reload
and the number doesnt appear in saved variables after 0

source
Code:
-- Author      : Andrew
-- Create Date : 5/28/2010 8:26:28 PM
local addonLoadedCount = 0;
local sessionCount = 0;
local currentDate = date("%m/%d/%y");
local currentTime = date("%H:%M:%S"); 

local function session_Info()
sessionDate = currentDate
sessionCounted = sessionCount
sessionInfo = sessionInfo or {}
sessionInfo[sessionDate] = sessionInfo[sessionDate] or {}
sessionInfo[sessionDate][sessionCounted] = sessionInfo[sessionDate][sessionCount] or {}

sessionInfo[sessionDate][sessionCounted] = {"number"}
print(sessionDate,sessionCounted)

end

local function onEvent(self,event,...)
----------------------------------------------
 if ( event == "ADDON_LOADED" ) then
addonLoadedCount = addonLoadedCount + 1;
currentDate = date("%m/%d/%y");

  if ( addonLoadedCount == 3 ) then
  print("GVLT Loaded")
   if ( sessionInfo == nil ) then
   session_Info();
   print("New Log File Begun")
   else
   session_Info();
   print("Log Begun/Continued")
    if sessionDate == currentDate then
    sessionCount = sessionCount + sessionCounted;
    print(sessionCount)
    else
    sessionCount = 0;
    end
   end     
  end
   
 end
   
 ---------------------------------------------
 if ( event == "GUILDBANKFRAME_OPENED" ) then 
  sessionCount = sessionCount + 1;
  session_Info();
  print("#", sessionCount, "of the day");
  
 end
 
 -----------------------------------------------

end

local evFrame = CreateFrame("Frame","evFrame",UIParent);
evFrame:SetScript( "OnEvent", onEvent );
evFrame:RegisterEvent( "ADDON_LOADED" );
evFrame:RegisterEvent( "GUILDBANKFRAME_OPENED" );
evFrame:RegisterEvent( "GUILDBANKFRAME_CLOSED" );
output
sessionInfo = {
["05/31/10"] = {
{
"number", -- [1]
}, -- [1]
{
"number", -- [1]
}, -- [2]
{
"number", -- [1]
}, -- [3]
[0] = {
"number", -- [1]
},
},
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Block too big?


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