Jump to content




Computers Reset When Move


  • You cannot reply to this topic
23 replies to this topic

#1 Lux

  • Members
  • 19 posts
  • LocationArgentina

Posted 30 August 2013 - 03:15 AM

Hi! I'm trying to open a door with Redstone In Motion but when the computer is moving it shutdown closing the wireless rednet conection. Any idea how to fix this or make a door like this?

The codes that I'm using:
Sender(Computer with the lock code):
term.clear()
term.setCursorPos(1,1)
rednet.open("back")
print[[
			  ----------------------
			  |SISTEMA DE SEGURIDAD|
			  ----------------------
			  Ingrese clave: ]]
term.setCursorPos(29,5)
local pass = "mypass"
local user = read()
term.clear()
term.setCursorPos(1,7)
if user == pass then
print[[
				------------------
				|Acceso concedido|
				------------------
				 Abriendo puertas]]
rednet.send(11,"Abrir")

else
print[[
				-----------------
				|Acceso denegado|
				-----------------]]
end
Receiver(computers beside to Carriage Controller):
rednet.open("top")
id, message = rednet.receive()
if message == "Abrir" then
shell.run("openr")
end

Texts are in spanish (like "sistema de seguridad" = "security system").
Thanks!

#2 Last1Here

  • Members
  • 32 posts
  • LocationUK

Posted 30 August 2013 - 04:30 AM

I assume this is a redstone in motion problem. So I don't think there would be a fix, unless you move the computer off the door.

#3 Pinkishu

  • Members
  • 484 posts

Posted 30 August 2013 - 04:49 AM

Same with MFFS.

MFFS people say CC has to fix it because of computers being a complex block or so :P
Not sure about RiM, but for MFFS i think it doesnt actually "restart" the PC but move it without moving the PC tileentity or state or something, causing the PC to startup again after the move with a new tileentity/state

I put a chat box thingy (from misc peripherals) on top of a PC and moved both with MFFS, the PC would read the chat event from the chat box and respond using the chat box, after moving now you got 2 responses though, after moving it again you got 3, etc; which hints to what i explained before

#4 Lux

  • Members
  • 19 posts
  • LocationArgentina

Posted 30 August 2013 - 05:11 AM

I read the WiM thread in Technik and it's a bug of ComputerCraft because when the CC is moved the chunks unloads and reloads so the computer will reboot. So I'll need get another form to conect the carriages to computercraft. Thanks for the replies!

#5 Pinkishu

  • Members
  • 484 posts

Posted 30 August 2013 - 05:44 AM

View PostLux, on 30 August 2013 - 05:11 AM, said:

I read the WiM thread in Technik and it's a bug of ComputerCraft because when the CC is moved the chunks unloads and reloads so the computer will reboot. So I'll need get another form to conect the carriages to computercraft. Thanks for the replies!

That would be a word behavior... why would the chunk be unloaded and reloaded Oo

#6 theoriginalbit

    Semi-Professional ComputerCrafter

  • Moderators
  • 7,332 posts
  • LocationAustralia

Posted 30 August 2013 - 05:52 AM

View PostPinkishu, on 30 August 2013 - 05:44 AM, said:

View PostLux, on 30 August 2013 - 05:11 AM, said:

I read the WiM thread in Technik and it's a bug of ComputerCraft because when the CC is moved the chunks unloads and reloads so the computer will reboot. So I'll need get another form to conect the carriages to computercraft. Thanks for the replies!

That would be a word behavior... why would the chunk be unloaded and reloaded Oo
Because a chunk doesn't do that when a Block or TileEntity is updated. The Technik people have no idea about how Minecraft works and are just stating things to make people not blame them. and instead blame someone else.

#7 Last1Here

  • Members
  • 32 posts
  • LocationUK

Posted 30 August 2013 - 10:25 AM

How can this be a CC bug when the computer work fine on redpower frames (1.4.7)?

#8 PixelToast

  • Signature Abuser
  • 2,265 posts
  • Location3232235883

Posted 30 August 2013 - 10:56 AM

View PostLast1Here, on 30 August 2013 - 10:25 AM, said:

How can this be a CC bug when the computer work fine on redpower frames (1.4.7)?
this is not redpower, shoo

#9 theoriginalbit

    Semi-Professional ComputerCrafter

  • Moderators
  • 7,332 posts
  • LocationAustralia

Posted 30 August 2013 - 11:05 AM

View PostLast1Here, on 30 August 2013 - 10:25 AM, said:

How can this be a CC bug when the computer work fine on redpower frames (1.4.7)?
'cause a lot in Minecraft has changed since 1.4.7... Also Elo did a lot of crazy magic behind the scenes when dealing with TileEntites, remember those crates, they did some pretty amazing and magical things...

#10 kreezxil

  • Members
  • 128 posts
  • LocationBowie, TX

Posted 30 August 2013 - 11:54 AM

Have you tried using a turtle instead of computer?

#11 jakj

  • New Members
  • 1 posts

Posted 30 August 2013 - 04:36 PM

Woah, woah, ladies and gentlemen, calm down.

1) We at Technic do know how Minecraft works, thanks: The person who "quoted" us didn't even understand what we said. The method that I use to move tile entities is to save and restore them via NBT, the same method the game itself uses when loading and unloading chunks. That's where the chunk comment came from: By design, ComputerCraft computers and turtles reboot when the chunk unloads/loads, or when the game is closed/opened. So it's not a bug in RiM and it's not a bug in CC: It's a limitation in CC.

2) Yes, Eloraam used magic in the form of special code to directly transfer tile entities and update them. I'm not doing that because a) It's a lot of work to keep up with N mods instead of just Minecraft, and I'm not getting paid to do it, and B) it doesn't survive crashing or saving/loading while a carriage/frame is in-transit.

This is all very simple: If ComputerCraft were ever changed so that computers/turtles retain their running state when saving to disk and being reloaded, this would suddenly start working in block-moving mods.

When initially developing my mod and discovering this issue, I did my own research, and found old threads discussing this that basically boiled down to "We know it's not ideal; We'd like it to work like that; Don't expect it to be changed because it's a lot of work and we have other priorities to deal with first.". That's fine: Computers/turtles function just fine, as long as people have enough of a clue to write intelligent 'startup' programs. It's a bit of a pain/hassle, but since it's easy to save/load local state in programs, it's by no means impossible.

#12 GammaPaladin

  • Members
  • 10 posts

Posted 20 September 2013 - 07:18 PM

I have a question related to this.

I understand the computer "restarts" every time it's moved. That's fine. I wrote my code around that limitation, but I've run into another problem.

My program basically lets the user give it a direction and a number of blocks to move the frame. The program checks the number, and if it's greater than 1, it writes a file to the disk with the direction and the distance that will still need to be travelled after it moves once, closes the file, and then moves one block in the direction specified.

After moving, the computer "reboots", and the startup program looks for the file, if it's there, it reads in the direction and distance, decrements distance, rewrites the file, and moves again (Assuming distance was greater than zero).

The thing is, this works, but only once. If I type in "drive n 5", it moves north, restarts, moves north again, and then just stops. The computer seems to stop restarting itself. If I right click the computer, it will start up and load the startup file and move again. If I keep right clicking after each move, it will eventually finish out the queued movements, and give me a prompt again. But it requires manual intervention after that second move.

Does anyone have any idea why this is? Is there any way I could work around it?

[EDIT: Just in case it might help, my code follows. I had to type it in by hand, don't know how (If it's even possible) to copy and paste out of a CC computer.

drive program:
local carriage = peripheral.wrap("bottom")

local args = {...}

local dir = -1
local dist = 1

if #args > 0 then
  if args[1] == "d" then
    dir = 0
  elseif args[1] == "u" then
    dir = 1
  elseif args[1] == "n" then
    dir = 2
  elseif args[1] == "s" then
    dir = 3
  elseif args[1] == "w" then
    dir = 4
  elseif args[1] == "e" then
    dir = 5
  end
 
  if #args > 1 and tonumber(args[2]) ~= nil then
    dist = tonumber(args[2])
  end
 
  if dist > 1 then
    dist = dist - 1
    local h = fs.open("movequeue", "w")
    h.writeLine(dir)
    h.writeLine(dist)
    h.close()
  end
 
  if dir ~= -1 then
    carriage.move(dir, false, false)
  end
end

startup file:
if fs.exists("movequeue") then
  local h = fs.open("movequeue", "r")
  local dir = tonumber(h.readLine())
  local dist = tonumber(h.readLine())
  h.close()
 
  local carriage = peripheral.wrap("bottom")
 
  if dir ~= nil and dist > 0 then
    dist = dist - 1
    
    h = fs.open("movequeue", "w")
    h.writeLine(dir)
    h.writeLine(dist)
    h.close()
    
    carriage.move(dir, false, false)
  end
end


#13 kreezxil

  • Members
  • 128 posts
  • LocationBowie, TX

Posted 21 September 2013 - 05:59 AM

View PostGammaPaladin, on 20 September 2013 - 07:18 PM, said:


-- snip --

[EDIT: Just in case it might help, my code follows. I had to type it in by hand, don't know how (If it's even possible) to copy and paste out of a CC computer.

-- snip --

If HTTP is enabled in your minecraft and you would know if it was cause you could use pastebin get cOdE file then you can also take all of your code and send it to pastebin and receive a code to give us by using pastebin put file.

#14 GammaPaladin

  • Members
  • 10 posts

Posted 21 September 2013 - 09:20 AM

Well, I'm the one administering the minecraft server so I can easily enable things like that. But I'm pretty sure I typed the code in correctly anyway.

Good to know for the future though, thanks.

#15 theoriginalbit

    Semi-Professional ComputerCrafter

  • Moderators
  • 7,332 posts
  • LocationAustralia

Posted 21 September 2013 - 09:37 AM

View PostGammaPaladin, on 21 September 2013 - 09:20 AM, said:

Well, I'm the one administering the minecraft server so I can easily enable things like that.
Also since you have access to the files, all computers save their code in /[path to server]/[world name]/computer/[computer id]/ replacing each of the values in [] with the appropriate value (note: to find out the computer id, run the `id` program on the computer).

#16 kreezxil

  • Members
  • 128 posts
  • LocationBowie, TX

Posted 21 September 2013 - 09:50 AM

View Posttheoriginalbit, on 21 September 2013 - 09:37 AM, said:

View PostGammaPaladin, on 21 September 2013 - 09:20 AM, said:

Well, I'm the one administering the minecraft server so I can easily enable things like that.
Also since you have access to the files, all computers save their code in /[path to server]/[world name]/computer/[computer id]/ replacing each of the values in [] with the appropriate value (note: to find out the computer id, run the `id` program on the computer).

Omg, I didn't know that one! Sure beats looking at all of the ids manually when you have over 80 turtles on the server.

#17 theoriginalbit

    Semi-Professional ComputerCrafter

  • Moderators
  • 7,332 posts
  • LocationAustralia

Posted 21 September 2013 - 10:09 AM

View Postkreezxil, on 21 September 2013 - 09:50 AM, said:

Omg, I didn't know that one! Sure beats looking at all of the ids manually when you have over 80 turtles on the server.
Well in that case, SSP computer files are in /[path to minecraft instance]/saves/[world name]/computer/[computer id]. A bonus addition of having access to the files that the computer uses is you can also edit them in a real editor instead of in-game. You can use something like Sublime Text 2 (cross-platform) and get a syntax highlighter for ComputerCraft, or you can use other things such as Notepad++ (Windows only) and edit in that with Lua highlighting.

#18 GammaPaladin

  • Members
  • 10 posts

Posted 21 September 2013 - 10:30 AM

Heck, even being able to edit them in pico is nice.

But I still can't figure out why the computer isn't starting up after the second move :/

I did edit my first post in this thread with copy-pasted code though, so it should be exactly accurate now, if it wasn't before.

#19 GammaPaladin

  • Members
  • 10 posts

Posted 21 September 2013 - 11:05 AM

Hmm. On a wild guess that the computer might be moving too fast for the server to keep up with updating its tileentity, I added a "sleep(1)" at the top of my startup script, and now it works fine. At least in singleplayer, where I'm testing it, as the minecraft login servers are down right now :/

So, solution appears to be, make sure there's a slight delay between moves when your computer is travelling with the frames, to allow the system to keep up.

#20 theoriginalbit

    Semi-Professional ComputerCrafter

  • Moderators
  • 7,332 posts
  • LocationAustralia

Posted 21 September 2013 - 11:47 AM

View PostGammaPaladin, on 21 September 2013 - 11:05 AM, said:

Hmm. On a wild guess that the computer might be moving too fast for the server to keep up with updating its tileentity
No this is not the case. Its impossible to happen, the Turtle and its TileEntity move immediately, all you're seeing is a 0.8 second long animation, and once this is completed it will send a "turtle_reponse" event to any Turtle function you've called (assuming you're not calling turtle.native.func), that function will then return and allow your program to continue. Actually to that point there was a beta with "super" Turtles which could all perform their actions about 4x quicker and the clients/servers could still perfectly handle that, and with the current state of technology in modern computing could handle much, much more!


View PostGammaPaladin, on 21 September 2013 - 11:05 AM, said:

I added a "sleep(1)" at the top of my startup script, and now it works fine.
Chances are that if this fixes your problem you have a bug else where in your code. Please provide us with all your code so we can further help with this problem.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users