on_activate=function(self, staticdata)
self.activated = true
end,
get_staticdata = function(self)
print(self.activated)
self.activated=nil
end
Termos wrote:Well the self exists only when the object is active, same with self.anything. What this code does is it sometimes sets active object's self.activated to nil.
Can you explain what it is you're trying to do?
Termos wrote:This doesn't say anything about what kind of tasks you'd want to perform on deactivation.
Termos wrote:Checking self.activated will only result with occasional false positives and calling on_deactivate for active objects.
BrunoMine wrote:The task is to create a callback to reach other tasks in the future. Does that answer your question?
BrunoMine wrote:Maybe I should even check if the self.object is nil to make sure it is deactivated?
BrunoMine wrote:I can make a luaentity copy and verify that the object still exists after 0.1 or more seconds.
local function luaexists(luaent)
if luaent and luaent.object and luaent.object:get_yaw() then return true end
end
Termos wrote:and because entities can disappear for various reasons, on_deactivate won't help you with that.
Termos wrote:Sure, but that's another topic, not related to callbacks and the self.
sorcerykid wrote:An on_deactivate callback would always be invoked any time the object is removed from the environment for whatever reason.
Users browsing this forum: No registered users and 3 guests