Yellow-Dog-Man / Resonite-Issues

Issue repository for Resonite.
https://resonite.com
131 stars 2 forks source link

Primitive Member Editor Used With For loop Will Not Iterate Properly #2349

Closed AmasterAmaster closed 2 months ago

AmasterAmaster commented 2 months ago

Describe the bug?

When using the Primitive Member Editor combined with a For Loop that allows for iterating using a ulong value, will not be respected and has undesirable results. Results such as not accounting for all iterations of a For Loop, and not even running the code even when connected.

To Reproduce

Create the standard Ref Hacking boilerplate of "Primitive Member Editor" component and attaching a text, text editor, and prepared ReferenceField of type IWorldElement as the target.

Next, Setup flux nodes in this order:

Lastly, with everything together, call an impulse for the For Loop, and you will notice strange things such as not all iterations are accounted for and the ending display node shows nothing has fired.

Expected behavior

Proper iteration using a ulong value combined with the component.

Screenshots

Provided is a snapshot taken of the flux nodes needed to replicate this bug.

Flux Setup - PME + For Loop

Resonite Version Number

Beta 2024.6.11.74

What Platforms does this occur on?

Windows

What headset if any do you use?

Index & Desktop

Log Files

Provided is this log file of when I successfully repeated this bug, I also used F3 before I pressed the call button on the For Loop.

ANDREW-SUPERPC - 2024.6.11.74 - 2024-06-16 04_05_55.log

Additional Context

I am aware that Ref Hacking is not supported, but this issue has nothing to do with it, as this is regarding the interactions between components and flux and the underlying issue of them causing the bug. I will report this issue here still, documenting that this problem exists and I will hope this can be tracked down and fixed some time in the future.

I will also provide a world resrec for anyone willing to look into this further: resrec:///U-AmasterAmaster/R-ab059294-064c-4270-9e46-1ac4a459c622

I have also been tracking down some other oddities and bugs with this component and flux interactions, and I have made reference to this before here: https://github.com/Yellow-Dog-Man/Resonite-Issues/issues/2348

Reporters

AmasterAmaster

art0007i commented 2 months ago

both issues you created (this and #2348) stem from incorrectly setup refhacking boilerplate. the TextEditor needs to have a reference to the text component for the setup to work correctly image

AmasterAmaster commented 2 months ago

How can one text field entry like that (from the TextEditor component) cause strange behavior @art0007i, maybe I am not aware of the underlying code that makes things work, or maybe it was not well documented when I was putting it together, but it is strange how one change can mean the difference between working and not working. I would like to learn more about this. >.>

art0007i commented 2 months ago

to be honest I just compared it to my own prefab I have saved to my inventory and this was the difference. but as a ground truth you can inspect an inspector that has a ValueField<RefID> and that will also show you how to set it up correctly because inspectors is where PrimitiveMemberEditors are intended to be used

both issues happen because the code assumes that the "Text" field on the TextEditor is populated and if it isn't it will cause a NullReferenceException. it doesn't world crash with a for loop because the exception doesn't propagate all the way and is handled somewhere else, but with the seconds timer I guess the exception propagates all the way up and causes a world crash

AmasterAmaster commented 2 months ago

I just confirmed that the loop works with this fix, I feel so stupid now... I will close this one shortly. And I also just checked the other world and issue and that also fixed it.

I do feel other nodes should be checked against this as well (Update, While Loop, etc). but other than that, I will make sure to let people know and I will write this down as a personal note to make sure to double check these things. Thank you.

AmasterAmaster commented 2 months ago

Resolved, I learned something today.