Jump to content

Custom Object not calling Create/Free correctly


Rick
 Share

Recommended Posts

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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. ><

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...