TeamOpenIndustry / ImmersiveRailroadingIntegration

GNU Lesser General Public License v2.1
1 stars 7 forks source link

Add a new API for OpenComputers Lua #1

Closed Simba98 closed 5 years ago

Simba98 commented 5 years ago

In my server, my high-speed railway system have an issue with getting the speed of locomotive. So I would suggest you add this API to OpenComputers Lua Script. Maybe my code style don't match yours, please also help to change it.

cam72cam commented 5 years ago

Instead, I'd prefer if you simply expose the info call as seen here: https://github.com/TeamOpenIndustry/ImmersiveRailroadingIntegration/blob/forge_1.12.2/src/main/java/cam72cam/immersiverailroading/thirdparty/CommonAPI.java#L53

You can see how this is done for the detector here: https://github.com/TeamOpenIndustry/ImmersiveRailroadingIntegration/blob/forge_1.12.2/src/main/java/cam72cam/immersiverailroading/thirdparty/opencomputers/AugmentDriver.java#L134

Simba98 commented 5 years ago

Well, it is a solution. The info() call expose all of properties. However, Lua scripts have to get all properties even if we just need one property. It may reduce the whole efficiency, and lag the server. What if we add a info(String property) call to increase that process? It receive a string that is property name and return the property requested.

cam72cam commented 5 years ago

That's a good idea, I like it!

Simba98 commented 5 years ago

Alright~ I'll do it later~ And make a new pull request for new idea.

Simba98 commented 5 years ago

But now it have a question: how can I deal with old 'get' APIs? Like getPos, getTag? Keep it for compatibility? Merge it into new property API? Or offer two ways to get Pos and Tag, etc. (Both new property API and old get series API can be used) I want to know your Design Philosophy, Thanks~.