Rick Posted December 19, 2009 Share Posted December 19, 2009 My custom object doesn't seem to be calling object:Free() and object:CreateObject() correctly and I can't figure out why. I have Notify() inside both CreateObject() and Free(). When I originally add it to the scene I get a "Inside create" message but when I run the game then exit the game you normally would get Free() called followed by CreateObject(), but for this object below neither get called. I must be doing something wrong. require("scripts/class") require("scripts/loop") --- create the class local class=CreateClass(...) function class:CreateObject(model) local object=self.super:CreateObject(model) Notify("Inside create") function object:Round(num, idp) local mult = 10^(idp or 0) return math.floor(num * mult + 0.5) / mult end function object:Free(model) Notify("Inside free") end function object:SetKey(key, value) end function object:GetKey(key, value) end function object:Update() end end Quote Link to comment Share on other sites More sharing options...
Rick Posted December 19, 2009 Author Share Posted December 19, 2009 The model to this object has the material.abstract::invisible.bmp applied to it. Would that have any effect on it? I wouldn't think so. The lights have the same thing. I'm very confused as to why this barebone object isn't having it's CreateObject() and Free() being called correctly. Quote Link to comment Share on other sites More sharing options...
macklebee Posted December 19, 2009 Share Posted December 19, 2009 you are loading this model by your game script? or are you talking about manually placing it in a scene then running a game script? Quote Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590 LE / 3DWS / BMX / Hexagon macklebee's channel Link to comment Share on other sites More sharing options...
Rick Posted December 19, 2009 Author Share Posted December 19, 2009 I place this object into my scene via drop and drag, then run the game script from the editor. I put Notify's inside other entities like lights and when I exit game mode they all call Free() then CreateObject(). So not sure why my entity here isn't. If I go into the script of my entity and save it, it does call Free() then CreateObject(), but not after the game mode is ran then exited back to the editor. Quote Link to comment Share on other sites More sharing options...
Rick Posted December 19, 2009 Author Share Posted December 19, 2009 Well here is something interesting. If I remove the SetKey() and GetKey() it works. So what am I doing wrong with those 2 functions that's causing issues? Bah, nevermind I copied from the template and it's working. Man that's a pain that because those 2 methods didn't return a value it totally hosed everything up. >< Quote Link to comment Share on other sites More sharing options...
Josh Posted December 19, 2009 Share Posted December 19, 2009 function object:Free() (no parameters) Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.