Extending Array Library on inline Interface Property
Hello,
I have a defined interface here:
I'd like to look at this line here
objects: ObjectData[];
The definition for ObjectData is below:
I would like to access ObjectData of a slot and use Array functions on it such as splice, however when I attempt to do so I get can error, I've attached it. The goal is to remove the particular ObjectData interface from the ObjectData[] array. If it is helpful, I have included my addobject method:
Thanks!
1 Reply
is there a way to remove a value in an array by its key in typescript
yeah
I think I found it
its .remove
wait nope
hmm
i don't care about the order of items, but for performance I'd like to be able to index each object by its ID
the IDs start at 0 and go all the way up. If an object is removed, I want to make the id available for a different object
maybe I need to rethink the array...
Right
thanks! ill try this out
this is user data, so I would like the most stable option.
Objects: [number, number, number, number, number, number, number, number, OldExtraObjectData][];
so this would change to map
oh, yeah i dont want accidental bugs lol
oh I see
ah just for organization, yeah
and for maps you do need to call .set?
how do I set an empty map, im new to typescript so I appreciate your help
objects: [],
this is for seting up the default userdata, ofc it needs to change because I've changed to maps
thanks!
also, what is Roblox TS's to number function for converting string to number
thanks!