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

Load chunk on modem.

Started by Sebra, 10 December 2012 - 02:48 AM
Sebra #1
Posted 10 December 2012 - 03:48 AM
Hi!

I found a village in a long distance from me. I want to setup a portal in it but do not want village chunks to be always in memory. So I suggest to think about…

Wireless Turtles (and may be Computers with Modems) loads it's own chunk if personal Wireless message received.
Only direct Id messages count.
Chunk loaded on several seconds only just for message to be received successfully and responded.

This method will allow to place replicators and routers without need of keeping that chunk always loaded.

It can be done by storing each Computer's coordinates in a table and loading needed chunk if needed. This can also easily detect duplicate Id's.

If you think this suggestion is bad, can you point out another way to load a chunk far away on command?
Sammich Lord #2
Posted 10 December 2012 - 04:37 AM
If they do it your suggested way then that will cause lag when ever it receives a rednet message.

while true do
  rednet.broadcast("Blah")
  sleep(5)
end
That will make the chunk load and un-load ever 5 seconds causing lag.
However, I cannot think of a way to do it without causing lag.
Sebra #3
Posted 10 December 2012 - 04:44 AM
I mentioned direct Id messages only. This mean no broadcast messages should wake up anybody.
Sammich Lord #4
Posted 10 December 2012 - 04:46 AM
I mentioned direct Id messages only. This mean no broadcast messages should wake up anybody.
I could still crash a server by going a few hundred blocks away, placing a computer and modem, going back and doing the same code just with rednet.send.
Cloudy #5
Posted 10 December 2012 - 04:53 AM
Nah. Would not be a good idea to load chunks on rednet message receive - even if direct ID. Malicious script to make all chunks with modems in the world be loaded, anyone?
CoolisTheName007 #6
Posted 10 December 2012 - 05:02 AM
This kind of thing got discussed somewhere sometime. Better than loading the chunk, some people suggest loading only computers; but that's still bad, because these computers might assume that they are in a loaded chunk and weird behavior may ensue.

Providing a special method for keeping computers loaded and an event for notifying of chunk unload would be a fix for that; they would only get rednet messages, and since CC deals with rogue computer coroutines by shutting them down, it's a solution both realist and safe.

Memory side, this still means groups of computers could uselessly stay online, all of them in unloaded chunks and unconnected to loaded chunks. So I suppose a connectivity test that would keep running computers that are connected (in range/linked by CClan, why not?) by anothers to a computer in a loaded chunk would be necessary, and that's at least possible, having in account that CCLan must have a found a solution for testing connectivity since someone said the messages don't crawl the cables anymore. In this unloaded mode, only some communication peripherals would work, and redstone/terminals would be disabled.

E.g., a turtle wakes up near an unloaded chunk with offline computers, and suddenly an entire network boots up. Notice that the bootup sequence is the problem. Lag issues ensue, but I suppose CC/MC has some kind of solution to deal with loading a lot of chunks at the same time? If not, it could just put a delay between boot ups.

What do you think?
Sebra #7
Posted 10 December 2012 - 06:34 AM
I could still crash a server by going a few hundred blocks away, placing a computer and modem, going back and doing the same code just with rednet.send.
And it will load single chunk. Is it so bad?
Nah. Would not be a good idea to load chunks on rednet message receive - even if direct ID. Malicious script to make all chunks with modems in the world be loaded, anyone?
Is it so hard to do malicious script now?
Make a global limit for number of chunks to be loaded by CC simultaneously. Let it be like 10 chunks. If waked up Computer want to stay loaded let it use other means.
This kind of thing got discussed somewhere sometime. Better than loading the chunk, some people suggest loading only computers; …
For my needs whole chunk must be loaded. So it is kind of separate problem.
CoolisTheName007 #8
Posted 10 December 2012 - 06:51 AM
If you think this suggestion is bad, can you point out another way to load a chunk far away on command?

You could try a chunk loader peripheral. Saw something like that somewhere.
Sebra #9
Posted 10 December 2012 - 07:15 AM
Have seen it. It keep chunk always loaded. And non peripheral chunkloaders too. But I want it loaded on demand.
Tiin57 #10
Posted 10 December 2012 - 09:33 AM
Have seen it. It keep chunk always loaded. And non peripheral chunkloaders too. But I want it loaded on demand.
I am remaking CCLoader. It will include a load chunk(x,z) function.
CoolisTheName007 #11
Posted 10 December 2012 - 09:39 AM
snip

Take in account, if possible, that he needs an unload(x,z) function too.
immibis #12
Posted 10 December 2012 - 10:39 AM
What about keeping computers loaded separately from the chunks they're in? Could be doable with the separating-computers-from-blocks stuff Cloudy (IIRC) is working on for PDAs. However you'd need new IPeripheral methods to get a chunk-independent object so unloaded computers can use peripherals like modems.
Tiin57 #13
Posted 10 December 2012 - 10:39 AM
snip

Take in account, if possible, that he needs an unload(x,z) function too.
Too many problems with an unload function. Also, this is not being designed to his needs/wants; it was already planned.
Cloudy #14
Posted 10 December 2012 - 12:23 PM
As I've said, I don't think this is a good idea. It doesn't have many use cases, as you can't do much in Minecraft without the chunk being loaded anyway. Even if Computers just stayed loaded, then it would use up memory unnecessarily for very little gain - not to mention the small matter of peripherals, which are very much tied into Minecraft blocks for computers.

If you want to load chunks, use one of the other capable mods to keep the chunk loaded. Loading it, then unloading it will probably be a greater load short term than keeping it loaded anyway.
bbqroast #15
Posted 10 December 2012 - 06:54 PM
Have seen it. It keep chunk always loaded. And non peripheral chunkloaders too. But I want it loaded on demand.
Why? That will only slow things down even more. When things are being loaded on demand your computer keeps having to read from a disk which would cause lots of lag. By using chunkloaders you atleast stop Minecraft constantly hogging disk IO.
CoolisTheName007 #16
Posted 10 December 2012 - 11:17 PM
Yeah, I was just pointing out what Sebra had asked, not my personal opinion; btw a chunk unloader could be useful in order to shutdown chunks that cause too much lag. The reason I had to suggest stand-alone computers was to keep the network control on the hands of the user, if ever anything is done to deal with between unloaded chunks communication. Not implying it should be part of the ComputerCraft; I'm talking about peripherals/addons/ComputerCraft itself
Sebra #17
Posted 11 December 2012 - 03:23 AM
I am remaking CCLoader. It will include a load chunk(x,z) function.
Can I see it? I hope x and z are relative.

May be most of you are right and to keep chunk loaded is less load on program than load on demand, but it is Village and I do not want Villagers to be attacked by Zombies. :(/>

I have to find way around.
basdxz #18
Posted 11 December 2012 - 03:36 AM
Why not make something that would allow server OPs/Mods/Admins load specific chunks on request? So that normal players can't load chunks while the server staff can? So if someone can cause lag it would be noobish staff that don't deserve their rank :P/>.