- Offizieller Beitrag
Moin,
aktuell scripte ich recht viel mit Metatablen bzw. Klassen. Jetzt ist mir bei einem setTimer jedoch aufgefallen, dass sich die Adresse der Table selbstständig und automatisch ändert.
Lua
myObject = {}
myObject.__index = myObject
function myObject.create()
local obj = {}
setmetatable(obj,myObject)
return obj
end
function myObject:doStuff()
outputChatBox("Toller Text!")
end
function timerCall(objectInstance)
outputDebugString(tostring(objectInstance)) -- INFO: table: 03D4EA60
objectInstance:doStuff() -- attempt to call method doStuff (a nil value)
end
local tollesObj = myObject.create()
outputDebugString(tostring(tollesObj)) -- INFO: table: 03D4DF20
setTimer(timerCall, 1000, 1, tollesObj)
outputDebugString(tostring(tollesObj)) -- INFO: table: 03D4DF20
Alles anzeigen
Wieso ändert sich die Adresse von "tollesObj" einfach so? Irgendwo muss da ja n Fehler drin sein.
MrX