PoroCoco / myaenetwork

Minecraft opencomputer LUA code to manage Applied energistic network from the web
MIT License
14 stars 6 forks source link

Environment Setup? And a few other questions #6

Closed FidgetySo closed 2 months ago

FidgetySo commented 10 months ago

I was wondering what your environment is for running this? I see that you also have a separate repository for the server side that uses flask. I am going to lay this out in different "sections" for ease of reading even if it might not help that much.... I am not really sure if this whole post is going to even look good of it's formatting.

I am sorry in advance for asking soo many questions at once and some of them might take some time to answer so sorry.... I am asking because I am working on a project that is very very similar however it's going to have a lot more capabilities than "just" managing a ME network. I wanted to test this project first to see what I can learn from it. I am probably not going to use a website but a desktop client made with Qt6 and python.

Hello !

Thanks for the message.

The GtDictionnaryString.py is only useful if you have the Gregtech mod inside your modpack as it's used to translate the cryptic Gregtech names into readable ones. If you have Gregtech in your modpack I can give you the script to generate it from the Gregtech.lang file. If you do not have Gregtech into your modpack then you don't need it and should change the line 19 of server.py from translateGTName = True to translateGTName = False

I'm currently working on remaking the code for the server and the ingame computers as it hurts to look at the code I wrote here, it has really bad performances and there is no documentation. I also closed the official website as there was no people using it anymore.

If you encounter any other problems feel free to ask me !

Thanks in advance again.

PoroCoco commented 10 months ago

I just finished rewriting everything for the OpenComputer part and web part so it's fresh in my mind. Don't worry about asking too many questions I don't mind if it can help someone.

What version of python and flask are you using and anything that was installed via pip, setuptools, conda, or anything else? A pip freeze would probably work just fine instead of answering manually

The version of python used is Python 3.10.12 and for the requirements its just a standard pip3 install for flask and oracledb. Actually you also need the gunicorn package but this is only useful for putting the web server in production.

What modpack are you using? I take it GTNH based on this line

Yes, but the program is independent from the modpack, it can be used in any modpack as long as there is OpenComputer and AE2. The only purpose of this line is to use an alternative function developped by the GTNH dev to get the items from AE without making too much lag if you're running it on the GTNH modpack.

Can I get the script if you still have it you had mentioned in this issue https://github.com/PoroCoco/myaenetwork-Server/issues/3 ?

The only use for this script was to translate the gregtech items names as OpenComputer wasn't giving the actual name. However this is not needed anymore (at least for GTNH) as the devs fixed that and the correct items names are now returned. The only case where this could be useful would be for the other gregtech packs like NomiFactory, but I don't even know if this issue exists on the other modpacks anyway. If you really need it I can search for it, but I don't have to use it anymore.

Would you like me to show you my project once it's to a "working" point? I am planning to add remote access for whatever OC has access to in Gregtech: New Horizons within reason. And hopefully a GUI based program that makes OC robots easier to program via being able to visualize them moving via symbols the represent different actions (arrows for moving, a chest for interacting with any inventory and so fourth) in a voxel grid that represents the space around the robot in-game. The actions are following along a line that portrays the order of the actions. The user can see this line and can also choose to only certain parts on it making it easier to debug and develop.

Yes I'd like to see this project ! I did have a similar idea after making this but never found the time to actually work on it. The robot idea gives me the same vibes as the project that ottomated did, take a look at this video.

Do you host the Minecraft server on the same computer that runs the server for this repository? Or on a separate computer on the network? Or something else entirely?

MAEN drawio(1)

So here's a quick overview of how it works : The user on the website connect to the web server and logs himself with his credentials. The web server ask a outside database to check the user information to allow the user to check his AE network if he has the correct password. This database runs a server somewhere hosted by Oracle, I just make requests to it. Then once the user is logged in, the server grabs the TCP socket that corresponds to the computer of the user then using this socket it uses a custom made communication protocol to ask the computer to send an updated view of the items in the network. The computer send the data over the socket and server display it to the user. So you don't need to have anything running on the same machine, the OpenComputer computers are each running on a different Minecraft server, maybe even using different modpacks. As the data is transmitted over a TCP socket your server/application can run anywhere. The main problem is that each computer need to initiate the TCP connection as it's impossible to make a TCP socket listen on the computer they can only connect to one, so the listening part is always on your server.

So why use TCP socket instead of the http requests ? The reason is that here the http requests are uni-directionnal, it will always be the computer asking the server, and the server giving some response. But it this case, and any application where reactivity is needed, the server needs to be the one notifiying the computer that an update is needed so once the socket connection has already been established you can do that, just have the computer wait for a new message on the socket and sent a corresponding response given the received message. Basically using sockets lets you have the computer waiting for some incoming commands which is not possible with http.

The complete flow for it to work is the following (given a new user that needs to create an account) :

If the user already has an account : First the OC computer needs to register its socket to the server :

If you need more informations or something isn't clear, don't hesistate to ask,

FidgetySo commented 10 months ago

Thanks for the reply. The explanation on why you switched to using TCP sockets instead of an HTTP connection probably just saved me a lot of time and hassle trying to figure out what would work better.

For the script I don't need it personally since I am playing GTNH however once I make my repo public I might add it incase if anybody else plays a modpack with Gregtech. So if you have it I would gladly accept it. And I won't forgot to add your repo as a credit/source.

The only use for this script was to translate the gregtech items names as OpenComputer wasn't giving the actual name. However this is not needed anymore (at least for GTNH) as the devs fixed that and the correct items names are now returned. The only case where this could be useful would be for the other gregtech packs like NomiFactory, but I don't even know if this issue exists on the other modpacks anyway. If you really need it I can search for it, but I don't have to use it anymore.

The project won't be done for about 6 months or so if not longer. It's going to be quite a while because I am developing a desktop client and it's going to have a lot mod integrations with it. Power generation and storage monitoring is one of the other features amongst many that I am hoping to do. Also would you like to add me on discord as better means of contact? my discord is .fidgety

Forgot to mention but I plan on adding support for "clusters" so one server/world can have multiple OC computers interacting as one user plus then you can have them spread out. I will also try to implant it where multiple computers can be used for one minecraft machine for an example an ME network. I had seen an implantation similar to this before. I believe this is it OCRemote