Author Topic: Auto Save  (Read 9163 times)

JookScript: Auto Save

Code: [Select]
function AutoSave(%name,%minutes);
{
schedule("" @ %minutes @ "000,savebuild," @ %name @ "");
schedule("" @ %minutes @ "000,AutoSave");
}

Has not been tested.

Usage: AutoSave(##SAVENAME##,##MINUTES##);

EDIT: Had to fix it so it'd loop.

Bad Idea... Better one:

Code: [Select]
function AutoSave(%name,%minutes);
{
schedule("" @ %minutes @ "000,savebuild," @ %name @ "");
$AutoSave= schedule("" @ %minutes @ "000,AutoSave");
}

function CancelAS()
{
cancel($AutoSave);
}

looks better so i trust that 1 xP

JookScript: Auto Save

Code: [Select]
function AutoSave(%name,%minutes);
{
schedule("" @ %minutes @ "000,savebuild," @ %name @ "");
schedule("" @ %minutes @ "000,AutoSave");
}

Has not been tested.

Usage: AutoSave(##SAVENAME##,##MINUTES##);

EDIT: Had to fix it so it'd loop.

Bad Idea... Better one:

Code: [Select]
function AutoSave(%name,%minutes);
{
schedule("" @ %minutes @ "000,savebuild," @ %name @ "");
$AutoSave= schedule("" @ %minutes @ "000,AutoSave");
}

function CancelAS()
{
cancel($AutoSave);
}

Bad idea, better one:

Code: [Select]
function AutoSave(%name,%minutes,%load,%cancel);
{
if ($cancel = cancel)
{
cancel($AutoSave);
}
else if ($load = load)
{
loadbricks("" @ %name @ "");
}
else
{
schedule("" @ %minutes @ "000,savebuild," @ %name @ "");
$AutoSave= schedule("" @ %minutes @ "000,AutoSave");
}
}

OOPS, Usage:

AutoSave(NAME,MINUTES,CANCEL,LOAD);

HMK

So you just type that into the console and it'll start autosaving? ( after setting it, of course)


What do I put in the Cancel and Load parts?

Code: [Select]
function AutoSave(%name,%minutes,%load,%cancel);
{
if ($cancel = cancel)
{
cancel($AutoSave);
}
else if ($load = load)
{
loadbricks("" @ %name @ "");
}
else
{
schedule("" @ %minutes @ "000,savebuild," @ %name @ "");
$AutoSave= schedule("" @ %minutes @ "000,AutoSave");
}
}
That won't work, it will give you a syntax error, good job, fix it. You need to TEST your scripts before you release them and you also need to ACTUALLY LEARN TO SCRIPT.

Ytud you need to learn to gtfo.

Come on, Jookia you aren't helping yourself.  Make something, test it til it works, THEN release.

Here's a fixed version of the previous code.  Whether Jookia's code works or not, harass him.  But at least now the code itself is correct.

Code: [Select]
function AutoSave(%name,%minutes,%load,%cancel);
{
     if(%cancel $= "cancel")
     {
          cancel($AutoSave);
     }
     else if(%load $= "load")
     {
          loadbricks(%name);
     }
     else
     {
          schedule(%minutes @ "000,savebuild," @ %name);
          $AutoSave= schedule(%minutes @ "000,AutoSave");
     }
}

I think you're trying to do too much in one function.  Take out the load part all together, it's easier to load from the ESC menu than to type all that in.  Also, just make the cancel a separate function.  The AutoSave should be just that, a function that automatically saves your work every few minutes.  Beside, it might even be easier if you're having users type in commands to just have them type in 'cancel($AutoSave);'.  Put a little planning into this, and you might do well.
« Last Edit: March 04, 2007, 03:05:32 PM by Trader »

Ytud you need to learn to gtfo.
stfu you idiot, the code was blatantly wrong.

I'm not saying that Ytud hasn't made mistakes in the past, but he is right.  It does the community no good to release things that haven't been tested to work.  If someone needs help with coding, there are people who are willing to help.  So please, do not release untested material.

HMK

So what do we put in the Load/Cancel parts? Or could you give us a completed example of a completed/working one and what it does?

rudyman

  • Guest
Code: [Select]
...
          schedule(%minutes @ "000,savebuild," @ %name);
          $AutoSave= schedule(%minutes @ "000,AutoSave");
 ...


I think %minutes@"000" would turn the minutes into seconds.
And both of those commands only have one argument, where there should be 3.

The format is: schedule([delay in milliseconds],[obj],[command]);
OR: [obj].schedule([delay in milliseconds],[command]);

So, here's how I'd do it:
Code: [Select]
function autoSave(%mins)
{
saveBuild();$AutoSave=schedule(%mins*60000,0,autoSave,%mins);
}

Although I'm not exactly familiar with the blockland commands, like saveBuild()
« Last Edit: March 04, 2007, 08:42:22 PM by rudyman »

Actually, it would be <minutes> * 60 * 1000 or <minutes> * 60000.

I would simplify this wayyy down.

function AutoSave()
{
     savebuild("AutoSave");
     $AutoSave= schedule(300000,0,AutoSave);
}

This would autosave every five minutes to the same file (Which to me, autosaves should use the same file, b/c it's there only as a backup.).  Then, when the user wants to disable autosave, just run the cancel($autosave);
« Last Edit: March 04, 2007, 08:45:43 PM by Trader »