Jump to content




Save lua state with game saves.


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

#1 Bromoc

  • New Members
  • 2 posts

Posted 04 April 2012 - 03:36 AM

The most frustrating issue i have is that the lua state isn't saved when the game is saved. this hurts the turtles more then the computers. yes i can write my programs to save there state to a file every time i process, but this increases perf and seems to break the illusion of persitance.

#2 Cloudy

    Ex-Developer

  • Members
  • 2,543 posts

Posted 04 April 2012 - 05:02 PM

I believe dan looked into this - there apparently seems to be no way to get the Lua state using LuaJ - however I'll mention it to dan next time I speak to him.

#3 Sebra

  • Members
  • 726 posts

Posted 05 April 2012 - 07:27 PM

Can turtle have some event when world saves/shutdown ?
So program has a chance to save some vital info in the right moment, not after each action.

#4 Xfel

    Peripheral Designer

  • Members
  • 515 posts

Posted 06 April 2012 - 01:35 PM

This would be technically possible. The shutdown code is run asynchronously anyway, so it could wait a bit.

#5 Hawk777

  • Members
  • 162 posts

Posted 06 April 2012 - 06:42 PM

The same would be quite nice to have for computers as well: a function (probably in the OS API) that registers a callback that's invoked just before the chunk containing the computer unloads.

#6 Sebra

  • Members
  • 726 posts

Posted 07 April 2012 - 06:27 AM

Event for chunk unload too. Or else unloaded turtle would be unable to save anything.

#7 Cor3y

  • New Members
  • 2 posts

Posted 19 March 2013 - 10:48 PM

something done in this direction? I'm really in need to get some informations to let a program be persisten on chunk unloading and server shutdown....

#8 oeed

    Oversimplifier

  • Members
  • 2,095 posts
  • LocationAuckland, New Zealand

Posted 20 March 2013 - 12:40 AM

This would be very useful, even if an event was called such as "will_shutdown" or something.

#9 Lyqyd

    Lua Liquidator

  • Moderators
  • 8,465 posts

Posted 20 March 2013 - 02:37 AM

This is, I believe, something that the developers are working toward.

#10 Cor3y

  • New Members
  • 2 posts

Posted 20 March 2013 - 03:40 AM

Let's hope! It would bring finally Computercraft programming to a whole other level!

#11 PixelToast

  • Signature Abuser
  • 2,265 posts
  • Location3232235883

Posted 20 March 2013 - 03:48 AM

i like the idea of an event before shutdown

#12 Lyqyd

    Lua Liquidator

  • Moderators
  • 8,465 posts

Posted 20 March 2013 - 03:53 AM

The time/effort spent adding an event (and resuming the computers again rather than shutting them down) would be better spent working on saving the Lua state, I would imagine. Especially so since it would be made useless by the change to state-saving.

#13 Cloudy

    Ex-Developer

  • Members
  • 2,543 posts

Posted 20 March 2013 - 03:59 AM

No event before shutdown. How many more times must we say no to that?

#14 Left4Cake

  • Members
  • 272 posts
  • LocationEarth

Posted 20 March 2013 - 07:43 AM

View PostCloudy, on 20 March 2013 - 03:59 AM, said:

No event before shutdown. How many more times must we say no to that?

You just add it to the "things not to ask" post.

View PostSebra, on 05 April 2012 - 07:27 PM, said:

So program has a chance to save some vital info in the right moment, not after each action.

Whats wrong with saving after each action?

#15 PonyKuu

  • Members
  • 215 posts

Posted 21 March 2013 - 04:56 PM

Performance? Let's say we have a bunch of turtles making a hole (yeah, I'm talking about my Turtle Swarm). Each time turtle moves, it should
1) Open a file
2) Write the data onto a hard drive (Real hard drive)
3) Close the file.

I'm not sure if server would like that, especially when 64 turtles do that each second. May be I'm wrong, though.

Actually, would that work? is there a chance that world would shutdown before the file closes?

#16 theoriginalbit

    Semi-Professional ComputerCrafter

  • Moderators
  • 7,332 posts
  • LocationAustralia

Posted 21 March 2013 - 05:18 PM

View PostPonyKuu, on 21 March 2013 - 04:56 PM, said:

Actually, would that work? is there a chance that world would shutdown before the file closes?
Very small odds of it happening. but not impossible.

#17 PonyKuu

  • Members
  • 215 posts

Posted 21 March 2013 - 08:09 PM

When there are a lot of turtles running, chances are not as small I think... Especially when you
1) Move the turtle
2) Update its coordinates
3) Save the data

#18 theoriginalbit

    Semi-Professional ComputerCrafter

  • Moderators
  • 7,332 posts
  • LocationAustralia

Posted 21 March 2013 - 08:24 PM

View PostPonyKuu, on 21 March 2013 - 08:09 PM, said:

When there are a lot of turtles running, chances are not as small I think... Especially when you
that is irrelevant. they aren't all moving and running their code at once, they all run individually, thats why the computers and turtles need to yield, so the next can run... the chances of having the server shutdown or the chunk unload in the exact millisecond before the file is saved is small... again, not impossible, just small...

#19 PonyKuu

  • Members
  • 215 posts

Posted 21 March 2013 - 08:38 PM

As far as I understand, that yielding can increase the chance that something bad happens between the turtle's movement and file updating, am I right?
I mean...

- turtle 1 moves
- turtle 13 does something
- turtle 2 does something else
- turtle 32 does other stuff
- Server shuts down before turtle 1 had a chance to save its state

#20 theoriginalbit

    Semi-Professional ComputerCrafter

  • Moderators
  • 7,332 posts
  • LocationAustralia

Posted 21 March 2013 - 08:44 PM

View PostPonyKuu, on 21 March 2013 - 08:38 PM, said:

As far as I understand, that yielding can increase the chance that something bad happens between the turtle's movement and file updating, am I right?
I mean...

- turtle 1 moves
- turtle 13 does something
- turtle 2 does something else
- turtle 32 does other stuff
- Server shuts down before turtle 1 had a chance to save its state
yeh so in that case, save before moving.

- turtle 1 changes its pos in file and then moves
- turtle 13 does something
- turtle 2 does something else
- turtle 32 does other stuff
- Server shuts down





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users