runi95 / turtle-control-panel

A website for monitoring and controlling ComputerCraft turtle activities
12 stars 2 forks source link

How to control the turtle? #10

Closed SolsticeSpectrum closed 1 month ago

SolsticeSpectrum commented 1 month ago

image So I have a turtle ready but what do I do? Is there supposed to be some GUI when i press move? It does not show up if so.

SolsticeSpectrum commented 1 month ago

I think it's just broken, using Build also does nothing even with block in it

SolsticeSpectrum commented 1 month ago

image I found the issue

runi95 commented 1 month ago

Right now I've heavily relied on the Geo Scanner from Advanced Peripherals to help see the world. I recommend refueling the turtle with some coal and then running Scan from the Geo Scanner peripheral (this means that you'll have to equip the turtle with a Geo Scanner). Once the scan has completed you'll have to refresh the page to see the 3D world (I want it to automatically update the world without a manual refresh, but that's currently a work in progress).

Currently you cannot really move the turtle without the world rendered first as you have no blocks to click on to move the turtle to.

The WebSocket connection might pose an issue later down the line, but it could also just be 1 failed connection followed by a successful one afterwards. It's hard to tell from your screenshot.

If you'd like to move the turtle without scanning the world first I'm up for suggestions on good ways to do this instead of just the point and click functionality.

runi95 commented 1 month ago

Moving

The black, transparent block to the right of the inventory shows up right underneath my mouse when I've clicked on the Move icon and if I left click after that then the turtle will start to move to that block.

I should probably make that more obvious though, especially when you haven't loaded in the world yet. I could also make it possible to click next to the turtle itself to move it.

SolsticeSpectrum commented 1 month ago

@runi95 Well turtle sees a block in front of it. If it could scan couple of blocks. I could make the mod to generate the data which would export directly as sql.

Alternatively couple of turtles with A* would be able to scan some blocks.

runi95 commented 1 month ago

The main reason I didn't go with this kind of discovery solution initially is that it's just so slow and methodical and I figured most people would have the Advanced Peripheral mod as the few packs I checked with CC:Tweaked had it.

That said it would probably be a good idea to have some sort of fallback solution for people that don't want to use Advanced Peripherals and still want to use this control panel. I'll look into it though. Meanwhile you're going to have to use the Geo Scanner if you want to discover blocks. It's really handy as it can discover entire chunks at a time.

SolsticeSpectrum commented 1 month ago

@runi95 Problem with Advanced Peripherals is the fact that it only exists for Forge, I'm playing All of Fabric modpack. Also Advanced Peripherals is stuck on 1.19. Forge for modern Minecraft kinda sucks anyway. Sodium and Iris is superior over Optifine and so on. There are a lot of Fabric modpacks and using any of them locks you out of the ability to use this tool.

Also I'll make the mod for fetching world for Fabric only as for Forge it's not really needed anyway. Does it sound good to you? I'll PR it when finished so it's part of this.

But there should still be fallback auto scanning which would make the turtle move around and discover it's world.

I'm also thinking about implementing texture sprite fetcher to the mod so you can have all blocks / items visible.

SolsticeSpectrum commented 1 month ago

image This ID should correspond to the database ID. Instead db ID is 1 and this ID is 9 for whatever reason. Tt will make the usage of the mod I am making much easier.

runi95 commented 1 month ago

I see now!

I think it's a great idea to make something like that for Fabric so that as many users as possible will be able to use this tool. I just haven't used Fabric myself and haven't really looked into using it so a PR from you on this would be very much appreciated!

And I agree, I'll look into a fallback solution for world scanning with no additional mods and pure CC / CC:Tweaked installed. It's going to be slow and it won't be able to scan blocks underneath blocks, but it'll still be useful for some.

Also the ID I'm showing is the ComputerCraft turtle's ID. And it's strictly speaking the same ID I'm using in the database. The primary key I've chosen in SQLite is turtles.server_id + turtles.id so a combination of 2 IDs together. It's not always that common to see composite primary keys like this, but I like the idea of using the turtle's internal ID as part of the reference instead of a completely separate one for all database calls. Hope this helps!

SolsticeSpectrum commented 1 month ago

@runi95 I am almost finished with the world dumping part. I still need to do some optimizing. Anyway I wanna add texture sprite exporter. Can you tell me how does the sprite works? How does it know which sprite corresponds to which block?

Wait that's just for the inventory. Where are block textures? I assume it's the atlas file. How is it structured? Can you explain the values?

runi95 commented 1 month ago

@DarkReaper231 It's a combination of the atlas and the atlas.map.json file. The atlas file contains all the png images merged together into a texture atlas kind of similar to the PNG file we have for the inventory render.

The atlas.map.json file contains information on how to render the model itself, this is nearly identical to how Minecraft stores their model rendering logic. It describes base models that all the other models can extend and defines each face of t he model.

If you want more information on how it works you can have a look at the code in the atlas-generator directory. The input it needs is just the Minecraft assets directory and from that it'll create both the atlas and the atlas.map.json file. It starts off by reading the atlas-generator/assets directory to see if there are any models to load, then loads all the models and then begins importing their texture files.

SolsticeSpectrum commented 1 month ago

@runi95 I figured a simplier way is just dumping the assets from mods so the mod can now do that too and you move the folder over atlas-generator.

Now does that also generate the sprite image or is that tool missing in this repository? If it's missing, can you add it? Ideally it should fetch it from assets folder as well.

runi95 commented 1 month ago

@DarkReaper231 Yes, just dumping the assets into the atlas-generator and then manually running the generator should render most of the modded blocks pretty well. We'll have some problems still which I haven't really looked too deep into yet, like the rendering of vanilla Minecraft doors is broken.

The sprites.png image is actually just manually made by me. I made that way before the 3D render and haven't really done anything with the inventory stuff since then. We could generate a sprites.png with the atlas-generator as well. It'll be a bit complex, but certainly doable.

runi95 commented 1 month ago

I've added very basic turtle exploration to the project now. It's not the most efficient, but not the least efficient way to explore either. I just used the D* Lite algorithm already in the project to make the turtle go to all locations within a chunk and then repeat the process until it either runs out of fuel, gets stuck or is manually stopped by the user.

I've enabled discussions for the repository and started a discussion on how to get world loading going for Fabric so we can continue the ongoing discussion about that over at https://github.com/runi95/turtle-control-panel/discussions