OpenMods / OpenPeripheral

https://openmods.info
MIT License
67 stars 25 forks source link

Terminal Glasses add component missing function #255

Closed alandoyle95 closed 8 years ago

alandoyle95 commented 8 years ago

I feel like this function should be added.. its a simple one, but i feel its needed.. unless i am wrong.

after you add a component (addBox, addText, addIcon, etc.) it returns an OBJECT of functions related to that component it generates an ID and it is never the same (as far as i can tell after you restart the computer it gets a different one) so i feel like there should be a getID function included in the returned object.

i feel like its a simple function that should have been added in from the start, but im sure that there are reasons it is not in there, but i have not found anyone else that has thought about this or has came up with a way of doing this.. only reason i found it was because im trying to make a stupidly complex terminal glasses program.

Sabbath93 commented 8 years ago

Have you tried turning it off and on again?

nevercast commented 8 years ago

Just to clarify, what would the purpose of having the ID be? Since after a computer/server restart the UI will need to be rebuilt, the ID doesn't provide any persistence.

nevercast commented 8 years ago

Also, an aside, the correct place to report this issue is https://github.com/OpenMods/OpenPeripheral-Addons/.

Don't worry about moving the issue, I can cross reference it from the other project. But just for future. Cheers.

alandoyle95 commented 8 years ago

sorry about that... and the ID would be used to detect clicking events for an object so that you can just make buttons and not have to use the X and the Y to determine it. it does not even have to be a function per-say, just being able to get the ID when the component is created would be enough. it would add more possibility to terminal glasses programs, and also be able to simplify some code.

my example of the use would basically be scroll bar buttons. to scroll though a list of items on the screen. and the code would be super simple if you could get the component ID, since it gives you what component you clicked on from the event pulled.

nevercast commented 8 years ago

Okay, it's been 2 years since I've touched OPA, can you tell me what values are given to you in a pullEvent?

alandoyle95 commented 8 years ago

https://gist.github.com/boq/9a098b89ee102cbf1b2b

there is a list :)

here is a list of all of the functions and there DOCS returned after you do addBox

http://pastebin.com/KpzP5Wm6

nevercast commented 8 years ago

Thanks, it looks like the Drawable object already exposes a getId() function, right next to the delete() function.

Have you tried this?

alandoyle95 commented 8 years ago

hmm.. its not in the list of objects returned.. i'll try that now and edit this post with the results..

nevercast commented 8 years ago

It's not a property, it's a ScriptCallable function, it might not be visible in the metadata of the object. Please check it and let me know.

alandoyle95 commented 8 years ago

ok, im semi smart when it comes to computercraft.. but i still have no idea what you just said. or how i would go about testing that.

nevercast commented 8 years ago

Just call getId() on the object returned by addBox (:

alandoyle95 commented 8 years ago

ok haha thats what i thought and it returns nil :(

nevercast commented 8 years ago

You can call delete on the object?

alandoyle95 commented 8 years ago

nope

alandoyle95 commented 8 years ago

i should note that im on version 0.3.1 more than likely not the most updated one.

nevercast commented 8 years ago

It was foolish of me not to ask for version information first. One moment I'll verify it works at my end.

alandoyle95 commented 8 years ago

yea its also my bad that i didnt check to see what the latest version was,

edit - found the change log..

nevercast commented 8 years ago

Do you have a date? Because it needs to be newer than Feb 5th this year https://github.com/OpenMods/OpenPeripheral-Addons/commit/6c54fe360ff8e71bc684fcc2a2f7304e5c5030e2

nevercast commented 8 years ago

Build 162 or newer

alandoyle95 commented 8 years ago

sadly i dont have a build number (using a pre made pack) but seems as though it all got added :D so thank you for your help, i'll just update the mods and then mess around with the new version!

nevercast commented 8 years ago

Let me know if updating does not work for you, between now and such time I should be able to actually test OPA. I only started developing again yesterday so no test environment for OP(A/I) yet.

alandoyle95 commented 8 years ago

will do!

alandoyle95 commented 8 years ago

Yep methods are all there and work :D AWESOME thanks for the help, here is the updated list of methods from addBox if anyone wants it...

http://pastebin.com/gFRGUvNr