#I need help in making a OOP function to destroy trash in my game without leaving any instances of it

1 messages · Page 1 of 1 (latest)

gusty violet
#

uh check if it exists first

crisp rose
#

try weak tables

#

if the referenced part is removed, it will also be removed from table

#

you should be able to just do TrashClass.__mode = "v"

#

iirc

#

I mean it will do exacly what you want no?

#

When you destroy tool you try to remove all references from table

#

Weak tables auto do that

#

If referenced part gets niled, reference is gone

crisp rose
#

It's just metatable

#

Which you're already using

#

Just add .__mode

#

Possible values are v k kv

#

V-value

#

K-key

#

Ye

#

Just double check it it causes mem leak or nah cuz I might be wrong but don't think so

#

Huh

#

Wdym

#

The class itself will be a weak table

#

Show

#

Maybe I fucked up something

#

Ye bc u try to clean up when it's already gone due to weak table

#

I think

#

What's the for loop for then

#

That has comment to litteraly remove reference

minor atlas
#

gc will collect it

naive leaf
#

as a developer who has been learning lua almost every day for over a year now I have never even heard of thiscrying Ik OOP, but like damn what is this

gusty violet
#

its classes...

#

what else

naive leaf
minor atlas
#

just keep making stuff

#

experience will teach you

harsh zodiacBOT
#

studio** You are now Level 32! **studio