Issues deleting objects

Creating Games? Developing something for fun?

Moderators: Klaus, FourthWorld, heatherlaine, kevinmiller, robinmiller

Post Reply
funfight22
Posts: 4
Joined: Sun May 15, 2016 9:04 pm

Issues deleting objects

Post by funfight22 » Sun May 15, 2016 9:19 pm

I am having issues with deleting my enemy graphics objects when they reach the end of the level. The program freezes, and I need to close and remove from memory to start it again. Here is the code for the delete function, it is located on the card.

Code: Select all

function deletePls toDelete
   delete graphic toDelete
end deletePls
And here is the object that calls it.

Code: Select all

on checkBounds
   global EKilled
   global raiders
   local myID
   
   if(loc of me is 1000,280) then
      put raiders + 1 into raiders
      add 1 to EKilled
      put "Raiders: " & raiders into field "Label Current Raiders"
      put long id of me into myID
      send "deletePls myID" to this card in 10 milliseconds
   else
      send checkBounds to me in 1 second
   end if
   
end checkBounds
I don't know what the issue is, from what I can tell it shouldn't have anything running when I am trying to delete it.

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2056
Joined: Sat Dec 22, 2007 5:35 pm
Location: Genève
Contact:

Re: Issues deleting objects

Post by jmburnod » Sun May 15, 2016 9:38 pm

Hi funfight22 , Welcome to this forum.
You use a function to delete target grc
On function return a value.
try (no tested)

Code: Select all

on deletePls toDelete
   delete graphic toDelete
end deletePls
instead

Code: Select all

function deletePls toDelete
   delete graphic toDelete
end deletePls
and dont forget declare

Code: Select all

global EKilled
   global raiders
   local myID
on the top of script
Best regards
Jean-Marc

funfight22
Posts: 4
Joined: Sun May 15, 2016 9:04 pm

Re: Issues deleting objects

Post by funfight22 » Sun May 15, 2016 9:48 pm

When switching the function to that it now comes up with errors saying that there is no such object, and livecode completely shuts down shortly after. All variables are declared earlier in the code.

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2056
Joined: Sat Dec 22, 2007 5:35 pm
Location: Genève
Contact:

Re: Issues deleting objects

Post by jmburnod » Sun May 15, 2016 10:09 pm

Sorry. I forgot long id = "image id 1003 of stack..."
try

Code: Select all

on deletePls toDelete
   delete toDelete
end deletePls
instead

Code: Select all

on deletePls toDelete
   delete graphic toDelete
end deletePls
You also can try

Code: Select all

 send "deletePls" && myID to this card in 10 milliseconds
instead

Code: Select all

 send "deletePls myID" to this card in 10 milliseconds

funfight22
Posts: 4
Joined: Sun May 15, 2016 9:04 pm

Re: Issues deleting objects

Post by funfight22 » Sun May 15, 2016 10:17 pm

Removing graphic from the function and changing how I send the ID to the function stops it from crashing, but it does not delete. I used freeze in my original post, to clarify I am unable to select objects to edit, or use like the main menu button, but the program is still running, for example one of my labels updates every second.

funfight22
Posts: 4
Joined: Sun May 15, 2016 9:04 pm

Re: Issues deleting objects

Post by funfight22 » Sun May 15, 2016 11:17 pm

If it helps, there are multiple clones of a non visible, disabled object. I clone it, set it to visible then put it on a path to move.

Post Reply

Return to “Creating Games”