Jump to content




[Question][Lua]Is there any way to make program reload


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

#1 exploder

  • Members
  • 69 posts
  • LocationLatvia

Posted 14 September 2012 - 05:33 PM

Hello everybody.

I am playing on MultiPlayer server (which isn't mine), and when you leave the server (when nobody is around your house), then everything stops.

And I have Mining Turtle Program who stops alwell, so I can't leave the server till it's finished.

And I wanted to ask you, is there any way, to make program reload (or continue) it's work, after you have been reconnected.

Here's the code, if that helps.

Spoiler

Thank you for reading.
-Exploder

#2 Cranium

    Ninja Scripter

  • Moderators
  • 4,031 posts
  • LocationLincoln, Nebraska

Posted 14 September 2012 - 05:41 PM

So are you wanting it to resume from where it left off? If so, then you will have to write into it a savestate file, where it knows where it was last, and resume from there. This is a litle bit of a pain to do, but can be done.

#3 exploder

  • Members
  • 69 posts
  • LocationLatvia

Posted 14 September 2012 - 05:46 PM

View PostCranium, on 14 September 2012 - 05:41 PM, said:

So are you wanting it to resume from where it left off? If so, then you will have to write into it a savestate file, where it knows where it was last, and resume from there. This is a litle bit of a pain to do, but can be done.

Thank you for replaying, and helping.

Yes, I want the program to continue where it left off last time.
Is there a chance, that you would show me a little example, how I should create one like that, or it's a bit too difficult to make?
Anyway's thanks for helping.

#4 Cranium

    Ninja Scripter

  • Moderators
  • 4,031 posts
  • LocationLincoln, Nebraska

Posted 14 September 2012 - 06:15 PM

local turtleX = 0
local turtleY = 0
local turtleZ = 0

local function savePos(x,y,z)
local file = fs.open("position","w")
file.write(x..","..y..","..z)
file.close()
end

local function tForward()
if not turtle.forward() then
turtle.dig()
turtle.forward()
end
turtleX = turtleX + 1
savePos(turtleX,turtleY,turtleZ)
end

Just a quick write up, not tested though. This is just for moving forward. you would have to adjust accordingly for Y and Z coordinates.

#5 exploder

  • Members
  • 69 posts
  • LocationLatvia

Posted 15 September 2012 - 08:09 PM

View PostCranium, on 14 September 2012 - 06:15 PM, said:

local turtleX = 0
local turtleY = 0
local turtleZ = 0

local function savePos(x,y,z)
local file = fs.open("position","w")
file.write(x..","..y..","..z)
file.close()
end

local function tForward()
if not turtle.forward() then
turtle.dig()
turtle.forward()
end
turtleX = turtleX + 1
savePos(turtleX,turtleY,turtleZ)
end

Just a quick write up, not tested though. This is just for moving forward. you would have to adjust accordingly for Y and Z coordinates.

Thank you, I will definitely try that out.





2 user(s) are reading this topic

0 members, 2 guests, 0 anonymous users