This forum is locked and will eventually go offline. If you have feedback to share you can find us in our Discord channel "MythoLogic Interactive" https://discord.gg/nECKnbT7gk

Forum rules

ObjectCreatedCallback does not work without ObjectTerminatedCallback

Here you can find all solved gameplay problems and bugs (beginning from Pre-Alpha 1.8.8).
Forum rules
By using the forum you agree to the following rules. For this forum you also need to follow these additional rules.
Locked
NearHuscarl
Superfighter
Superfighter
Posts: 97
Joined: Thu Feb 07, 2019 4:36 am

ObjectCreatedCallback does not work without ObjectTerminatedCallback

Post by NearHuscarl » Thu Aug 08, 2019 3:03 pm

Code: Select all

        public void OnStartup()
        {
            Events.ObjectCreatedCallback.Start(OnObjectCreated);
            // Uncomment the line below and it will work again
            // Events.ObjectTerminatedCallback.Start(OnObjectTerminated);
        }

        public void OnObjectCreated(IObject[] objs)
        {
            foreach (IObject obj in objs)
            {
                Game.WriteToConsole(string.Format("Object {0} ({1}) created", obj.UniqueID, obj.Name));
            }
        }

        public void OnObjectTerminated(IObject[] objs)
        {
            // objects terminated. Note: This is run just before the object is about to be destroyed or removed. To see if it was destroyed, check the IObject.DestructionInitiated property.
            foreach (IObject obj in objs)
            {
                Game.WriteToConsole(string.Format("Object {0} was {1}", obj.UniqueID, (obj.DestructionInitiated ? "destroyed" : "removed")));
            }
        }
Events.ObjectCreatedCallback doesn't register the callback event. Only work if you add an object terminated callback event alongside with it
Last edited by JakSparro98 on Thu Aug 08, 2019 8:55 pm, edited 1 time in total.
Reason: Changed the title to better reflect the issue
1 x
Image

User avatar
Gurt
Lead Programmer
Lead Programmer
Posts: 1887
Joined: Sun Feb 28, 2016 3:22 pm
Title: Lead programmer
Started SFD: Made it!
Location: Sweden
Gender:
Age: 36

Post by Gurt » Sat Aug 10, 2019 10:13 am

Fixed after v.1.3.0b
0 x
Gurt

Locked