This file is indexed.

/usr/share/doc/sludge/SLUDGEDevKitHelp/The_Worlds_Easiest_Load_Save_Mechanism.html is in sludge-doc 2.2.1-1build2.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<TITLE>The World's Easiest Load/Save Mechanism</TITLE>
  <link rel="stylesheet" type="text/css" href="style.css" />
</head>
<BODY>
<HR>
<div align="center"><img id="headerGraphic" src="images/sludge300.png" alt="SLUDGE"/></div>
<h2>The World's Easiest Load/Save Mechanism</h2>
<HR>

<P>
In order to give your game a unique look and feel, it's entirely reasonable to want to code your own load and save routines with text entry, lists of existing games and so on. However, if you're just getting started on a game, here's the simplest way to get a loading and saving mechanism working. Set up a keyboard handler (if you don't have one already) and add these two lines (assuming the variable it's checking is called k - if not change the code appropriately).
</P>

<P>
<pre>if (k == &quot;s&quot;) saveGame (&quot;saved.gam&quot;);
if (k == &quot;l&quot;) loadGame (&quot;saved.gam&quot;);</pre>
</P>

<P>
Easy! Of course, you might want to do more than just call the <a href="saveGame.html">saveGame</a> and <a href="loadGame.html">loadGame</a> functions. You may want to let people pick a slot to save into, for example. Feel free to use and build on this...
</P>

<P>
<pre>objectType saveSlot1 (&quot;&quot;) {}

objectType saveSlot1 (&quot;&quot;) {}

objectType saveCancel (&quot;&quot;) {}

sub myGameStuff (clickFunc) {
   freeze ();
   pasteString (&quot;SLOT 1&quot;, 25, 65);
   addScreenRegion (saveSlot1, 20, 20, 100, 100, 0, 0, -1);
   pasteString (&quot;SLOT 2&quot;, 125, 65);
   addScreenRegion (saveSlot2, 120, 20, 200, 100, 0, 0, -1);
   pasteString (&quot;CANCEL&quot;, 125, 65);
   addScreenRegion (saveCancel, 120, 20, 200, 100, 0, 0, -1);
   onLeftMouse (clickFunc);
}

sub saveGameClick () {
   var clickedWhat = getMouseOverObject ();
   if (clickedWhat) unfreeze ();
   if (clickedWhat == saveSlot1) saveGame (&quot;saved1.gam&quot;);
   if (clickedWhat == saveSlot2) saveGame (&quot;saved2.gam&quot;);
}

sub loadGameClick () {
   var clickedWhat = getMouseOverObject ();
   if (clickedWhat) unfreeze ();
   if (clickedWhat == saveSlot1) loadGame (&quot;saved1.gam&quot;);
   if (clickedWhat == saveSlot2) loadGame (&quot;saved2.gam&quot;);
}</pre>
</P>

<P>
And in your keyboard handler...
</P>

<P>
<pre>if (k == &quot;s&quot;) myGameStuff (saveGameClick);
if (k == &quot;l&quot;) myGameStuff (loadGameClick);</pre>
</P>

<P>
There are much more advanced load and save examples on the SLUDGE website - and 
<a href="Download_Free_SLUDGE_Examples.html">here's how to get there</a> if you'd 
rather dive in at the deep end and swim from there.
</P>


<H3>See also:</H3>

<P>
<a href="deleteFile.html">deleteFile</a>
</P>

<P>
<a href="fileExists.html">fileExists</a>
</P>

<P>
<a href="getMatchingFiles.html">getMatchingFiles</a>
</P>

<P>
<a href="loadGame.html">loadGame</a>
</P>

<P>
<a href="renameFile.html">renameFile</a>
</P>

<P>
<a href="saveGame.html">saveGame</a>
</P>

<P class="copyright-notice">SLUDGE and this SLUDGE documentation are <A HREF="Copyright.html">copyright</A> Hungry Software and contributors 2000-2012
</P>

<HR>
</BODY>
</html>