lua-users home
lua-l archive

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


the setglobal tagmethod has 3 parameters: varname, oldvalue, newvalue
and the getglobal tagmethod has 2 params: varname, value and should return a
value

hope that helps,
Peter

-----Original Message-----
From: owner-lua-l@tecgraf.puc-rio.br
[mailto:owner-lua-l@tecgraf.puc-rio.br]On Behalf Of Michael Flad
Sent: Tuesday, September 25, 2001 3:40 PM
To: Multiple recipients of list
Subject: get/setglobal


Hi,

i think i must be really stupid today, whats wrong
with these simple lines of code.
At the last line Hello has the value nil and so
the call fails.

Lua calls setglobal for "Hello" while executing the
function definion and i expect a value of type
"function" as second parameter but what i get is "nil".
Am i missing something here?


function GetGlobal( varname )
  print( "Get global: "..varname )
  rawget( globals(), varname )
end


function SetGlobal( varname, value )
  print( "Set global: "..varname )
  rawset( globals(), varname, value )
end


settagmethod( tag(nil), "getglobal", GetGlobal )
settagmethod( tag(nil), "setglobal", SetGlobal )


function Hello()
  print( "Hello called" )
end

Hello()


TIA,

Michael Flad

--
Fantastic Realms Interactive GmbH
Birnenweg 15 - D-72766 Reutlingen
Germany