PC-Logix / OpenSecurity

Security addon for OpenComputers
MIT License
47 stars 24 forks source link

[Suggestion] Magreader lights can be controlled #171

Closed cadergator10 closed 2 years ago

cadergator10 commented 2 years ago

Is your feature request related to a problem? Please describe. There are 3 lights on the magnetic card readers, which I would think would be extremely helpful if they could be controlled by lua code.

Describe the solution you'd like A function like magreader.setLight(false,false,true) --First is red light, second is yellow, third is green. Maybe also a function to disable the automatic lights (where the light turns green if the card is read)

Describe alternatives you've considered There aren't really alternatives I can think of.

Additional context I am working on a security system with open security, and was wondering if I could use the lights to indicate the door was open with the light, or if access is denied. It would be a HUGE quality of life change.

cadergator10 commented 2 years ago

I edited the code on my fork I have in github here https://github.com/cadergator10/OpenSecurity I don't even know if it will work or doesnt have bugs as I dont know how to mod minecraft (I looked through code to figure out how it changes the texture) If it does work and is bug free, then it has two new functions on the magreader block: swipeIndicator takes in a true false which will cause the indicators to light up when swiped (normal function) Default is true changeLight takes in a number from 0 to 3, which corresponds to the meta value of the magreader, with 0 being idle, 1 being error, 2 being active, and 3 being success. I don't remember if these are the actual function names because I closed the gitpod (another reason I think there are bugs in code, gitpod doesn't work very well with modding)

cadergator10 commented 2 years ago

I can't even test if it works because I can't figure out how to set up the workspace on my pc. I cloned it with github desktop, and it says there is no minecraft library

ben-mkiv commented 2 years ago

chances that this will be implemented soon are low, but if you want to build your own OpenSecurity file it should be sufficient to run the gradlew build task, i'm not sure how to do it on windows but probably from command line running

gradlew.bat setupDecompWorkspace and then gradlew.bat build

but the mod has a bunch of build dependencies which you may have to download on your own

also from a quick look at your changes, they are missing the save/load of the current state, so the block would forget it's state when the world or chunk gets reloaded (edit: may not apply to the blockstate actually, but the variable in the TileEntity)

ben-mkiv commented 2 years ago

btw. you could take a look at https://github.com/PC-Logix/OpenLights which allows you to set the light color for the block with OpenComputers (beside of that it also looks neat with albedo/mirage installed)

cadergator10 commented 2 years ago

Thank you for all the help! I managed to make it so you can control the cardreader lights.

ben-mkiv commented 2 years ago

you can make a Pullrequest with the changes and it will be eventually merged with the next update

ben-mkiv commented 2 years ago

PR: https://github.com/PC-Logix/OpenSecurity/pull/172

I'll leave the issue open so that i don't forget to merge it next update. And thanks for your contribution :)

cadergator10 commented 2 years ago

I'll leave the issue open so that i don't forget to merge it next update. And thanks for your contribution :)

Your welcome :D I forgot to mention that you might want to remove the changes to the mcmod.info file, as thats another thing I forgot to remove from the pull request. I might fix all those when I get home

cadergator10 commented 2 years ago

Updating on the progress: I fixed the maglights by performing the scheduleBlockUpdate in the tileentitymagreader. It all works normally now

cadergator10 commented 2 years ago

Closing due to pulled request