[SOLVED] Get Deleted object position for extension via function onDestroy

In normal events i can simply do this


And when i right click on stone it will create another stone left from deleted one
I could even store position of deleted stone in variable
My guess is that since it is same action it don’t have time to register object being deleted
So it is still there when game get it position and so based on that i am able to do whatever (create another object in this case)

But for function onDestroyed in extension it won’t work

And my best guess is that whatever event’s we have in that function
Like ones i have here

Are separate event so 1st object gets deleted and then any following event occurs

I need some way to determine position of that deleted object in that function
Or whatever other trick even leaving something there would be good enough for me like other object or changing opacity of surrounding objects

I think saving each object position as separate variable could be solution
Like imagine i have dynamically given variables for each object on scene at beginning of the scene and then set it to their position on map
But then problem would be comparing what was existing before deletion vs after
I could limit checks to affect only objects that are on the screen
But still i doubt that is perfect solution

If someone have any idea how to solve it or any workaround i am all ears or eyes in this case

I had to test your code. I was surprised the events after the wait were executed since by that time the object should be deleted. You can get the x,y when the function is first triggered and use them or store them in a variable but the wait lets the game continue so any code after the wait doesn’t have an object to reference. Honestly, I don’t think any events after the wait should even run once the object gets deleted. I would avoid using the wait it could interfere with the object cleanup.

If the behavior doesn’t process things as frequently as the objects are deleted then you could add the x,y or any other property to an array of structures like a buffer. Your other function could check the buffer or a boolean and then delete the children afterwards.

It would probably be best to process things as they happen. Make sure all variable names are unique by including the behavior name to prevent conflicts with other scene variables.

1 Like

OW MY GOD i told you i am dumb
Last time i told you im dumb i told you i already had all the answers i need right in front of my nose 4 times already
Well here comes 5th
I did not consider to store position in scene or global variable then simply use these coordinates as spawning point instead i went with
Object.X()-object.Width()
Object.Y()
Not even considering problem is that not that coordinates don’t save but object does not exist anymore so it can be referenced again
But its coordinates actually can and will be saved

And works like a charm
Right click any stone with empty grid cell to the left

Red area is what i did and it is working
I had hard time understanding what you mean with “wait” working in your reply
Did you mean what is in green area?
If so then that wait is my trick to switch boolean from 1 state (true/false) to other state so if i have true and false in 1 action it don’t act as ONLY last one listed is there
So if in this case last is False state and i had no wait action there
For game it would be as if there was only false state triggered
Not even triggering True state even so it’s there
Also BTW just so you can understand my spaghetti
This boolean triggers that event which checks all objects on screen
It is not doing anything else other than act as on of switch that works just for 1 frame to trigger different event
That’s why it works

Now again BIG THX idk how to thank you and if you don’t know what you just give me well this is my holly grail of checking only center and adjacent neighbors objects both on creation and destruction of new object
So i could ditch Is On Camera extension
And well slowdown/freeze reduce up the roof

So thx again i wish to mention you if you want in list of ppl that helped make this extension come true
But i won’t do it until you give me permission to do so so here i ask

You want to be mentioned in this extension as person thanks to who this extension even exist or no?

1 Like

If you want to mention me in any form, that’s fine. I’m glad to help.

I understand your boolean is a trigger. I’m just wondering why you need to reset it. Is there a reason why the function that waits for it to be true doesn’t set it back to false when it’s done? It’s just seems more efficient to immediately return the value to false. I’m guessing it might be bc of all of the instances but I’m still unfamiliar with behaviors.

I need to test how behaviors work bc I’m still a little unsure of the sequence things happen.

1 Like

Call it good practice
You need to understand my logic
Imagine you are making idk buttons on your screen simple UI buttons like options on/off and idk change camera from follow player to drag mode
And under that buttons you leave some text
I did for my test project

Under camera button you have zoom level under cursor button you have angle of cursor to player under save button you have RTC

Now tell me what you would do i mean where you would place that text in events?
Would it be under event with each button or would you create separate group called button text and put them all there because latter seems like more logical thing to do and would keep crap more organized

In my case far from true i learned the hard way that if i gonna edit button i MAYBE also gonna edit text under it so i should not go to different event group and find that text in list of other text objects
That’s why it should be right next to object it belongs to
Not convinced?
Imagine i am moving button 3 pixels to the left now where that text would be easier for me to find to also move it 3 pixels to the left? Next to that button or in separate group of its type? Eh?
And for same reasons i also never stick text to objects since idk how i gonna change it later and 1 change even to font can mean re-arranging all that crap
Not to mention text moved on button in X axis most of the times need adjustment also on Y axis and vice-versa
And same thing you see here with boolean
I don’t need something else to turn it off i need it to work in 1 single event so if i am to change anything or try something different i have on/off switch in 1 place instead looking trough events which one of them is disabling my boolean
I need to stay in true state instead of switching to false state
It may sound stupid but i learned the hard way to avoid doing stuff that can lead me into hours of searching for 1 thing and figuring why it is not working
That’s why i do stuff the way i do it is not most elegant but in my eyes most efficient for my workflow
For example i never use compare 2 numbers i always print crap to variable and check if variable is < = > than other variable and that leaves me always variable to print or to use in other expressions
I do not need to remember what was expression for comparing angle between player and cursor i have variable for that named CursorAngle
Which is way shorter than AngleBetweenPositions(Player.CenterX(), Player.CenterY(), CursorX(), CursorY())
This is not rocket science but look in how many words (considering i have dyslexia) i can make mistake while on other hand i could simply type CursorAngle

I hope you see now my point of doing crap
And i will mention you and damn again wall of text
I have really bad habit of doing walls

1 Like

I always say use what works for you. we all see and process things differently. Again. I wish you the best.

1 Like

Thanks and i hope now it will be downhill work for me

This won’t be wall of text again but i forget to mention most important feature of that boolean
I know the difference between back THEN i was young and better now THAN later
Yet i can write THAN you need only to click this button and i won’t see mistake in it
That kind of dyslexia i have and same goes with making events
I simply sometimes don’t see stuff being wrong even so i look directly on it
Imagine with my boolean i gonna use it for 5 or 10 different events
And most likely in 1 or more of them i gonna forget to switch it back to false
With my method i only need to care about checking for state of that boolean
I don’t need to even remember to switch it back for each other event
And that is already a possible problem avoided which in my eyes is problem solved before it even have a chance to become a problem

1 Like