Skip to content

Latest commit

 

History

History
33 lines (26 loc) · 2.14 KB

README.md

File metadata and controls

33 lines (26 loc) · 2.14 KB

CC-Tweaked-Turtle-Controller

Controlling a Turtle From the Minecraft Mod CC: Tweaked using an Electron UI through a websocket connection. Idea inspired by Ottomated.

This idea is fairly simple, but annoying to implement (especially with little prior knowledge of websockets, electron, threejs, etc.).

If I were to do it again, I wouldn't use javascript (or at least, I'd try to limit my use of it). Typescript, or a similar language, would have likely been a better option, to make troubleshooting easier.

The project is essentially broken into 3 parts.

  1. The Websocket Server
  2. The Renderer Process
  3. The Turtle Client

The websocket server is easy enough to implement. Using the ws module, it's straightforward enough to do. After establishing a websocket connection, the server creates a corresponding turtle object, which is saved into an array. The status of this turtle is checked every 5 seconds with a ping test. Communication with the turtle will be done through this object, with a command queue to allow the turtle to finish it's current task before being handed another.

The renderer is electron, combined with threejs, and is easily the most difficult/time-consuming part of the project since I had to learn both (I'm also pretty bad at css), as well as the basics of blender to create a turtle model. The renderer process sends requests to and recieves data from the main process via electron's ipc.

The turtle client is fairly simple, being made in lua with all the basics of turtle control and websocket management all being provided with the CC:Tweaked mod. Lua is a language of which I know little about, which has caused quite a bit of headache, especially since it contrasts so heavily against languages like C++, of which I'm more familiar with.

Overall, some things I've learned from this project include:

  • Class and object utilization
  • Event based programming
  • Event queueing
  • (Some) Promise handling
  • Lua
  • Websocket connections and servers
  • The basics of html requests
  • Heartbeats
  • Electron
  • Inter-Process communication
  • ThreeJS
  • Creating simple 3D models using primatives in blender
  • Creating reflectivity in models
  • Creating simple uv maps