lua-users home
lua-l archive

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


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