Saving the contents of a stack in another file

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
nrmair
Posts: 2
Joined: Thu Dec 12, 2013 10:19 am

Saving the contents of a stack in another file

Post by nrmair » Thu Dec 12, 2013 10:29 am

Hello forum members,
Ok so my problem is that I can't figure out how to save my stack in another file which can then be opened from within the stack again. Currently I am studying computing at school and must complete a project with several "complex" functions so as to get a good grade. I have made a text based game and one of the complex functions I thought would be good was the ability to save the progress made in the game. Unfortunately I can't quite find a way of saving anything other than text to another file. I tried the "save" command but that literally saves the stack which I guesses would be the case. So my question is, is it possible to save the content of everything in a stack to file in a way that it can be opened again like other games offer? The idea being that I need to save the contents of certain variables that have changed due to the players actions such as picking up items etc. Any help is much appreciated. Thank you!

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Re: Saving the contents of a stack in another file

Post by Mark » Thu Dec 12, 2013 11:09 am

Hi,

If you want to save the coordinates of buttons, the contents of images etc., you might as well save the stack itself in a writable place. Just make a splash stack that either opens the stack or creates a new one:

Code: Select all

put specialfolderpath("documents") & "/app name/stackwithcontents.rev" into myPath
if there is a stack myPath then
  go stack myPath in new window
else
  clone stack "your substack" // this stack is now open
  save it as myPath
end if
Kind regards,

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

nrmair
Posts: 2
Joined: Thu Dec 12, 2013 10:19 am

Re: Saving the contents of a stack in another file

Post by nrmair » Thu Dec 12, 2013 3:45 pm

Ok Mark, I will give this a shot tomorrow as that is when I have my next lesson, thank you very much

Post Reply