Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
manage objects automatically
#11
(11-14-2023, 05:12 PM)aliensoldier Wrote: I have created two examples based on the one you have shown me of oop, one with a list and the other without a list 

The one that uses the list library works fine, but the one that doesn't use the list library I can't get the trigger to be eliminated when exiting the screen. 

I show you the two examples and you can tell me where the error is or you can make a version of your example without using the list library

Sorry for the delay, got busy yesterday, but I've had a look at your code now Smile

I replaced
Code:
free deadList[i]
in Father_Update with
Code:
free val fatherList, deadList[i]

The new line removes the object in deadList from fatherList. That is, 'free val x, y' removes any occurrence of y from the array/table x and re-indexes the array (removes any holes).

Code:
function Father_Update()
    if sizeof(fatherList)
        for i = 0 to sizeof(fatherList) -1
            fatherList[i].Update()
        next
    endif   
   
    if sizeof(deadList)
      for i = 0 to sizeof(deadList) -1
          ' Marcus
          'free deadList[i]
          free val fatherList, deadList[i]
      next
    endif
    clear deadList
endfunc

You should never use 'free' when working with arrays. Always use 'free val' (remove any occurrence of a value) or 'free key' (remove an index/key and its value).
Reply


Messages In This Thread
manage objects automatically - by aliensoldier - 11-11-2023, 07:01 PM
RE: manage objects automatically - by Marcus - 11-11-2023, 09:46 PM
RE: manage objects automatically - by Marcus - 11-12-2023, 09:10 AM
RE: manage objects automatically - by Marcus - 11-13-2023, 02:57 PM
RE: manage objects automatically - by Marcus - 11-14-2023, 04:30 PM
RE: manage objects automatically - by Marcus - 11-16-2023, 04:13 PM
RE: manage objects automatically - by Marcus - 11-14-2023, 07:47 PM
RE: manage objects automatically - by Marcus - 12-09-2023, 09:28 PM
RE: manage objects automatically - by Marcus - 12-18-2023, 04:08 PM
RE: manage objects automatically - by Marcus - 12-18-2023, 05:11 PM
RE: manage objects automatically - by Marcus - 01-18-2024, 04:49 PM

Forum Jump:


Users browsing this thread: 2 Guest(s)