This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
Aichan's profile picture

[Peripheral] Remote Chunk Loading peripheral

Started by Aichan, 10 January 2013 - 11:53 AM
Aichan #1
Posted 10 January 2013 - 12:53 PM
Well, before throwing rocks at me, please read it carefully :

What is a "Remote Chunk Loading" peripheral
The peripheral would be some kind of advanced world anchor. First of all, it attaches to a turtle/computer just like RichardG's chunk loading turtle /!\ BUT /!\ that peripheral would be like a rednet modem waiting for a message to be activated, and another to be disactivated

What the hell do you mean?
Let's say you have a turtle/computer on an unloaded chunk, you want to contact you'd need to chunk load it. But why not load it with an event? like turtle.wake(id). But you don't want the computer to be loaded when you don't use it (God damnit, think about the bill !) so you also want it to be unloaded at will !

What not just RichardG's peripheral?
If you're still wondering that, I guess I wasn't clear enough so to make it clear, I don't want the chunk where the turtle/computer is to be always loaded, if you're playing with 200 of these turtles, that would mean 200, in the best case, chunks loaded EVERYTIME

An example to be clear :

- A fixed server is placed in a certain position with a World Anchor (so it's never unloaded)
- That server is able to wake (= chunk load) some computer/turtles, redned it some message
- The entity awaken is kept chunk loaded for a specified time (or waiting for a shutdown message)
- The entity is shutdown, chunk is unloaded

And why would that be super awesome?

I want to do a web interface that makes you able to control your turtle from outside game, so you could help people on your server without being physically there. That would open nearly infinite possibilities without any lag problem
Cloudy #2
Posted 10 January 2013 - 01:03 PM
It isn't possible to rednet.send a computer that is not awake. No chunk loading capabilities are coming as default either.
Aichan #3
Posted 10 January 2013 - 01:09 PM
The rednet would be a bit fake, more sending an event to Java telling it to load a partical chunk, then the real message would be like "link etablished"

So there's no way to load a specific chunk at will?
Cloudy #4
Posted 10 January 2013 - 01:11 PM
Of course there's a way - but it isn't easy, and not something we would consider for inclusion in the actual mod anyway.
Aichan #5
Posted 10 January 2013 - 01:16 PM
Guess I'll have to wait and keep all those turtles alive …
Cloudy #6
Posted 10 January 2013 - 01:18 PM
Someone else could make that peripheral - perhaps suggest it as an enhancement to RichardG?
Aichan #7
Posted 10 January 2013 - 01:24 PM
Yeah actually I posted it here to have something to give to him, is he reachable on IRC since I see him away really often?
CoolisTheName007 #8
Posted 10 January 2013 - 01:40 PM
Ok, was talking with Aichan just now, asked me to add what I said before, so:

Chunk loaders seem to have evolved since the last time I looked at them, at leat those on direwolfs20 FTB modpack. They is a limit of chunkloaders per player, and they consume enderpearls to function; if such supply isn't easily automatable (for instance, it has to be refiled by an actual player), and if a chunkloader peripheral for turtles is made to work in the same way, it would be safe to give all players the right to use chunkloaders.
(To avoid lag, up until now most servers blacklisted them)
For this particular use (remotely starting up a turtle), it would be awesome to pre-program the chunkloader to load the chunk upon receiving an external signal. Not sure what would be an interesting signal in general;
In your case, your script would have to interact with the minecraft java-side somehow, and for instance throw an event that the peripheral class would catch. Last resource, would be your script writing to a file it's requests (and deleting old ones), and java reading it regularly.
A rednet msg would oblige to have the rednet emitter loaded, even if the message is caught java-side (where the chunks activation ensues).
Safety constraints are similar to those restricting your web editor: delays between loading/unloading the same chunk, maximum number of chunks loading at the same time, ect.

Pretty much like simulating a new kind of player, the automaton (the turtle), which requires a pre-intervention from a real player to be able to 'play' for a limited time.

Compared to chunk-loading peripherals,that already implement something like:
-activateChunkLoader()
-deactivateChunkLoader() <- needs to be protected against spamming, and possibly have a global action queue of chunk loaders to deactivate, making a sleep between each.


the new stuff, java-side, would be:
-implementing behavior that I've already seen in recent chunkloaders:
need a player-only refill of a resource (like enderpearls), so there is a time limit for the chunk-loader to be active without player interaction, and there is a limit of active chunk-loaders per player;
-loadComputer(id,player)
would check if the said chunk loader peripheral is present in the turtle/computer with said id, properly filled, and belongs to @player, and if so, load the chunk where said turtle is, turning on the chunk loader.
This function needs to be protected against spamming,e.g. a global queue with a delay between chunk loaders activations.


To actually do what the OP wants, an interface between Java and it's server script is necessary, that would gather requests of the type (id,player). The actual authentication of the player connecting through the OP web interface is another story, but it isn't done java-side.

Activating chunks from in-game in this restricted fashion also seems useful, so adding this to the Lua chunkloader peripheral methods would be nice:
–activateChunkLoader(id)
Would call loadComputer(id, [player username of who placed the peripheral which is calling loadComputer]).


Note: both queues have to be protected against duplicates of the same requests (identified by chunloaders), by not queuing them again; a delay between unloading and loading a same chunkloader is also a good idea.

EDIT: checked out forge api for chunkloading, seems this would involve keeping track of where the chunkloader is and requesting new tickets each time it crosses a chunk.
Cloudy #9
Posted 10 January 2013 - 01:43 PM
I don't understand where all this talk of "throwing events for Java" comes from. Java doesn't use events.

Anyway, not gonna happen in vanilla CC.


Yeah actually I posted it here to have something to give to him, is he reachable on IRC since I see him away really often?

You can try messaging him when you see him active - you can recognise his activity by his AMSG's! You can also try PMing him on the forums.
CoolisTheName007 #10
Posted 10 January 2013 - 01:50 PM
I don't understand where all this talk of "throwing events for Java" comes from. Java doesn't use events.
Forge events
Tiin57 #11
Posted 10 January 2013 - 01:53 PM
Do you want me to revive my remote chunk loader peripheral?
Aichan #12
Posted 10 January 2013 - 01:54 PM
What's its behaviour?
Tiin57 #13
Posted 10 January 2013 - 01:55 PM
It's a block.
It's a peripheral.
When wrapped, it exposes

loadChunk(x, z)
That's about it.
Oh, and it has some pretty crappy textures courtesy of yours truly.
Cloudy #14
Posted 10 January 2013 - 02:00 PM
I don't understand where all this talk of "throwing events for Java" comes from. Java doesn't use events.
Forge events

But why would you need to use a forge event… That makes no sense. Forge events are not useful for communication within your own mod.
Aichan #15
Posted 10 January 2013 - 02:00 PM
Looks nearly exactly what I needed, but what about unloading chunk? How long does it keeps it loaded? Is there a way to keep it loaded until an unload call is made?
Tiin57 #16
Posted 10 January 2013 - 02:03 PM
Looks nearly exactly what I needed, but what about unloading chunk? How long does it keeps it loaded? Is there a way to keep it loaded until an unload call is made?
I suppose I never thought about that. I don't like messing with unloading chunks; too many bad things can happen. I leave that up to the automatic unloading system.

I don't understand where all this talk of "throwing events for Java" comes from. Java doesn't use events.
Forge events

But why would you need to use a forge event… That makes no sense. Forge events are not useful for communication within your own mod.
Forge events are not at all what you want here, Cloudy's right; only modders should care about the Forge events. If the mod is coded right (which CC is), then players should have no interaction with them.
CoolisTheName007 #17
Posted 10 January 2013 - 02:03 PM
Do you want me to revive my remote chunk loader peripheral?
It would be kind of different.
We need features such as tracking a block and loading chunks in a radius around it (e.g. tracking the turtle), not loading a specific chunk. That would be something.
Though, it's a start to have an actual peripheral developer interested!
Tiin57 #18
Posted 10 January 2013 - 02:06 PM
Though, it's a start to have an actual peripheral developer interested!
Yeah, I suppose I'm interested. :P/>
The only reason I abandoned my old one was because I felt no care from the community. I don't publish mods to exercise my writing skills. :P/>
CoolisTheName007 #19
Posted 10 January 2013 - 02:12 PM
Forge events are not at all what you want here, Cloudy's right; only modders should care about the Forge events. If the mod is coded right (which CC is), then players should have no interaction with them.
When I talked about events, I was indeed talking about java-side stuff: the OP needs some interface between his php (is it php) script (see the original idea) and the java peripheral that can load chunkloaders. One way to go about it is to use events; in general, to implement such a thing as queue of chunks to load, with delays in-between, that don't block, events and event handlers are one way. Plus I've been working on my scheduler too much, sorry.
Aichan #20
Posted 10 January 2013 - 02:16 PM
Well you'd really save us if you developped that mod !

So basically what would be perfect is :
It has to be a peripheral (To be attached to moving turtles) (rednet support is a plus)
We need some way to activate it (Through Lua for example, so it could be used from in-game)
We need some way to desactivate it (The turtle doesn't act like a keep-chunk-loaded entity)

And also, thank you in advance !


My main purpose with that mod is to interface the turtle with a Web interface, so you could control your turtle from outside the game, and for other people, they could possibly control their army or turtle wherever they are from a server, just waking them up from a single monitor
Tiin57 #21
Posted 10 January 2013 - 02:19 PM
It'll happen.