lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Hi,

Another (newbie) question here (and I did RTFM first - but it isnt sinking
in yet!:-)

Ok,

I have a function to print the name of a node (a tolua'd data structure)

function printName( node, ... )

	print( node:getName() )

end

I want to be able to call printName with some optional arguments. In my
print example I want to call it with an "indent level" number which the
function can key-off & print appropriate tabs before writing the name as
above.

Another function is supposed to get passed the exact same argument &
increment/decrement the value which will be used in printName.

so at the top level I have code like:

level = 1
printAll(root,level)  where printAll is defined as printAll(node,...)

I believe my level number value is put into a table & passed to varargs
functions as a table. Hence in my vararg functions Ive tried...


	indent_level = arg[1]
	indent_level = unpack(arg) // not sure what/when or why i'd use the unpack
func?????
	indent_level = tonumber(arg[1])


	my intention being that I could then...

	arg[1] = indent_level + 1 --or minus 1


when I try to use any of my indent_level assignments above I get an error in
the for loop (to print the tabs) about indent_level not being a number!!!

Im a bit confused and I couldnt find an example which seems to do what i'm
doing - so any help appreciated!:-)

Thanks

Andy

ps
Lua is very cool though!