-
Notifications
You must be signed in to change notification settings - Fork 230
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Equality comparisons for ELEMENTS and :CREW are broken #3117
Comments
Nope that is things working as they should. Most data structures in kOS are not stored in vars by value and instead stored by reference and for most cases when you preform an equality check on references if they are not the same reference then you get What you need to do is write your own by value equality check which compares something that you can get by value unique to the structure. For elements you would likely need to iterate the part list of both elements and check that the UID for all parts in one list is found on one part of the other list. EDIT:
|
Does this still happen since b9aad87 ? |
This still happens. As nuggreat said this is how things are expected to work. On every access to these suffixes a new list is created. No simple way I see to fix this short of renaming all these suffixes to something like |
Elements is broken right now, for example,
ship:elements = ship:elements
returnsFalse
, same withship:elements[0]:parts = ship:elements[0]:parts
orcore:element = core:element
, and searches in lists of elements is impossible withship:elements:find(ship:elements[0])
returning-1
andfor elem in ship:elements{print ship:elements:indexof(elem).}
returning-1
. I do not know what is causing this. The same problem appears to be with the:crew
suffix,ship:crew = ship:crew
orship:crew[0] = ship:crew[0]
returningFalse
, butship:crew:name
seems to be fine.The text was updated successfully, but these errors were encountered: