Thread Tools Display Modes
05-29-10, 02:26 AM   #261
Xrystal
nUI Maintainer
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 5,877
If you read the error message it is telling you that key1 happened to have been a string value and not a number. And the line is trying to use it in an arithmetic formula. Bad juju.

Your best bet to identify why that is, is to use the print(type(key1),key1) command just before that line to see what it is currently holding. If it shows a value you were expecting but still not working I think the function is tonumber which converts a string formatted number into an actual number. That might then solve your problem for that line.
__________________
  Reply With Quote
05-29-10, 03:11 AM   #262
Torhal
A Pyroguard Emberseer
 
Torhal's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2008
Posts: 1,196
I'm re-posting your code properly indented (for easier reading/comprehension) with notes on things I found...interesting.

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 recordingSessionInfo()
	-- sessionInfo is assigned as an empty table if it doesn't already exist.
	sessionInfo = sessionInfo or {}

	-- Despite the above, sessionInfo is assigned as a completely new table which contains yet another table.
	sessionInfo = {
		currentDate = {   
		}
	}
end

local function recordingNewSession()
	-- sessionInfo is assigned as a new table which contains another new table, which itself contains another new table.
	sessionInfo = {
		currentDate = { 
			sessionCount = { 
			}
		}
	}
end



local function onEvent(self,event,...)
	----------------------------------------------
	if ( event == "ADDON_LOADED" ) then
		addonLoadedCount = addonLoadedCount + 1;

		if ( sessionInfo == nil ) then
			recordingSessionInfo()
			print("New Log File Begun")
		else
			if ( addonLoadedCount == 3 ) then
				print("GVLT Loaded")
				for key,value in pairs(sessionInfo) do 
					-- This should really read as "if value ~= currentDate then"...
					if not( value == currentDate ) then
						print("Current Day Log Loaded")
					else
						-- Insert _what_ into sessionInfo?
						tinsert(sessionInfo)
					end           
				end
			else      -- This doesn't need to exist, at all.
			end    
		end
	end
end  -- This was added by me, but needs to be there.
Code formatting is integrally important to proper understanding of the code - if you can't easily see what belongs where it becomes nearly impossible to see what is happening logically.

Parenthesis are not required in most cases, unless you need to disambiguate something due to parsing order.

Semicolons are not required at all - they are there mainly for transition for people used to languages such as C and C++.

I strongly suggest that you read the PiL - I cannot stress this enough. I know you are eager to get something up and running but without fully understanding the mechanisms required to do what it is you are trying to do, you will end up causing yourself much more frustration than actually learning Lua and thinking about the logic of the code would cause.
__________________
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.

Last edited by Torhal : 05-29-10 at 03:15 AM.
  Reply With Quote
05-29-10, 08:52 AM   #263
Xrystal
nUI Maintainer
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 5,877
I'm afraid the parenthesis and semi-colons are all my fault Torhal. As you said, I am used to c++ and alot of it is habit now rofl.
__________________
  Reply With Quote
05-29-10, 11:11 AM   #264
Torhal
A Pyroguard Emberseer
 
Torhal's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2008
Posts: 1,196
I come from a C and C++ background as well, but broke myself of the habit rather quickly - I just think of Lua in natural-language terms...

Code:
if not insane then RunAway() end
versus

Code:
if (!crazy) {
    do_flee();
}
Code examples can be rather interesting when first waking up.
__________________
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-29-10, 12:40 PM   #265
clowcadia
A Chromatic Dragonspawn
Join Date: Apr 2010
Posts: 186
hehe thanks torhal, and crystal

to torhal int he code you were asking what to insert on the else function, if it happens to be that else it will insert the new table with its new date

to crystal

lol thank you i am working with tonumber atm.. not willing to post the progress, because i may just need to find out on my own, and mean whole i am getting confused why everything is made to be in the code rofl
(understand what it does, but no thinking why do i do that)P
  Reply With Quote
05-29-10, 03:20 PM   #266
Xrystal
nUI Maintainer
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 5,877
Originally Posted by clowcadia View Post
hehe thanks torhal, and crystal

to torhal int he code you were asking what to insert on the else function, if it happens to be that else it will insert the new table with its new date

to crystal

lol thank you i am working with tonumber atm.. not willing to post the progress, because i may just need to find out on my own, and mean whole i am getting confused why everything is made to be in the code rofl
(understand what it does, but no thinking why do i do that)P
Good, ask the question to yourself. Take the code out. Put it in. Print the value if one exists and then see if that helps you answer the question
__________________
  Reply With Quote
05-29-10, 05:17 PM   #267
Torhal
A Pyroguard Emberseer
 
Torhal's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2008
Posts: 1,196
Originally Posted by clowcadia View Post
<snip>
to torhal int he code you were asking what to insert on the else function, if it happens to be that else it will insert the new table with its new date
<snip>
You have this in the code:

Code:
	tinsert(sessionInfo)
The reason I was asking what is being inserted is that tinsert is shorthand for table.insert() which is use like this:

Code:
	table.insert(table, value)
In your code, you are inserting absolutely nothing into the sessionInfo table.
__________________
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-30-10, 02:28 AM   #268
clowcadia
A Chromatic Dragonspawn
Join Date: Apr 2010
Posts: 186
been reading around tables,and ready programming with lua, and the explanations are very complex, and the coding is not very relative with the functions we use for wow. i had read such sites before i came here, and hence the reason i am still in this topic even now after been taught by graceful crystal. i find that programming with lua is for more intermediate coders, who have coded other languages that are just as complex like c++. where as i have only really coded HTML back maybe 5-6 years ago, and never bothered to touch php
so please spare me the frustration, and either guide me in the right way maybe help me understand the programming with lua site with examples. or give up on me
i personally dont ask for all your time, i just hope that i get some kind of help at some point. we are on forum only because we reply if we wish to and post if we need to. i do not expect someone to do this for me but i hope that someone could help me before my mind blows up from rocket science

i got 2 problems that cant be found in any documentation, or too complex to relate to
Code:
sessionValue = tonumber(sessionCount);
sessionInfo = { 
}
tinsert( sessionInfo, currentDate , sessionValue )
hmm understand
but is there a limit to what the value is?
because i got my value a subtable == [currentDate]
but when i do tinsert( sessionInfo, [currentDate] )
id gives me an erro
been trying this as well on it but nothing
tonumber(sessionValue)

btw the currentDate = date(its variables) and it displays the data correct in saved variables

Code:
local function recordingSessionInfo()
sessionCount = sessionCount + 1;
sessionInfo = sessionInfo or {}
sessionValue = tonumber(sessionCount);
sessionInfo = { 
}
tinsert( sessionInfo, currentDate, sessionCount )

end
Code:
local function onEvent(self,event,...)
----------------------------------------------
 if ( event == "ADDON_LOADED" ) then
addonLoadedCount = addonLoadedCount + 1;
sessionCount = sessionCount + 2;

  if ( addonLoadedCount == 3 ) then
  print("GVLT Loaded")
   
   recordingSessionInfo();

Last edited by clowcadia : 05-30-10 at 03:52 AM.
  Reply With Quote
05-30-10, 11:18 AM   #269
clowcadia
A Chromatic Dragonspawn
Join Date: Apr 2010
Posts: 186
just to note, my last post have been edited
  Reply With Quote
05-30-10, 05:02 PM   #270
Xrystal
nUI Maintainer
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 5,877
Your code.
Code:
local function recordingSessionInfo()
    sessionCount = sessionCount + 1;  
    sessionInfo = sessionInfo or {}
    sessionValue = tonumber(sessionCount);
    sessionInfo = { 
    }
    tinsert( sessionInfo, currentDate, sessionCount )
end
tinsert only needs 2 parameters, the destination table and the source data.
tinsert(table,data)
data however can be anything, a number, a string. Even a table.

So, try changing the tinsert line to something like the following and see how different it looks in the variables file.
tinsert( sessionInfo, { currentDate, sessionCount } )
or
tinsert( sessionInfo, { ["Current Date"] = currentDate, ["Session Count"] = sessionCount } )

This would make the table look as follows:
Code:
sessionInfo = {
     currentDate,       --1
     sessionCount,     --2
}   --1
or

Code:
sessionInfo = {
     ["Current Date "] = currentDate,       --1
     ["Session Count"] = sessionCount,     --2
}   --1

Dependant on which way you do it.
__________________
  Reply With Quote
05-30-10, 09:05 PM   #271
clowcadia
A Chromatic Dragonspawn
Join Date: Apr 2010
Posts: 186
thank you crystal
  Reply With Quote
07-06-10, 09:29 AM   #272
Zahnspange
A Kobold Labourer
Join Date: Jul 2010
Posts: 1
I read the thread and like what you have done. Anyway a chance to get the whole as a zip or rar file or something?

Thanks
  Reply With Quote
07-06-10, 09:55 AM   #273
Xrystal
nUI Maintainer
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 5,877
Originally Posted by Zahnspange View Post
I read the thread and like what you have done. Anyway a chance to get the whole as a zip or rar file or something?

Thanks
I haven't done anymore work on this, but the following is the last status of the addon I used to test the different functions out for this thread. Feel free to use it for your own addon requirement but it may need some work

Whether clowcadia has done more investigation on this or not I don't know.
Attached Files
File Type: zip GuildBankTransactions.zip (4.2 KB, 890 views)
__________________
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Trying to see guild bank transaction information

Thread Tools
Display Modes

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