A 'how to make a castle' tutorial...|
We have our castle, nicely drawed out and everything, we can walk around.. etc.
Let's make it a bit more spiffy shall we?
I'm thinking a corridor that collapses after a certain amount of time?
So here we go!
A warp function goes a little something like:-
function Warp(x, y, layer, map)
var script = "";
if (map != undefined && map != "undefined" && map.length > 0)
script += "ChangeMap('" + map + "'); ";
if (x != undefined && x != "undefined")
script += "SetPersonX('" + GetInputPerson() + "', '" + x + "'); ";
if (y != undefined && y != "undefined")
script += "SetPersonY('" + GetInputPerson() + "', '" + y + "'); ";
if (layer != undefined && layer != "undefined")
script += "SetPersonLayer('" + GetInputPerson() + "','" + layer + "'); ";
And we put that in a trigger on the map as:-
Warp(42, 254, 0, "frey.rmp");
The map != undefined && map != undefined means that if you put nothing, or "undefined" as the map, it wont go to it...
Next we discuss save points...
Firstly, add this to your script:-
That now means (as long as you get the file from my files page) that you can use my interface for saving...
Here we go:-
Outside of any function, you put:-
var saveslot = new save_slot();
And whenever you want to recall something you do:-
var number_of_swords = saveslot.read("number_of_swords", 0);
Now number_of_swords is 0 or whatever it was last time...
// change swords or whatever
And then we save it...
There isn't a load function, so don't worry.
How do I get it to start where I last was?
Create a blank map...
With nothing in it...
Map Properties... Entry Script:-
And then in one of your scripts:-
var x = saveslot.read("player_x");
var y = saveslot.read("player_y");
var layer = saveslot.read("player_layer");
var map = saveslot.read("player_map", "default map.rmp");
Warp(x, y, layer, map);
The blank map just acts as a place to start the map engine.
You then want to add someway of calling a SaveGame function, it looks like this:-
I'll just use a person entity, but anywhere that you use it it's the same...
Right click on the map, insert person...
On Talk Script : SaveGame();
Now we want that final thing, the timer...
var start_time = 0;
var time_limit = 15 * 1000; // 15 seconds
start_time = GetTime();
var time = GetTime() - start_time;
var seconds = (time_limit - time) / 1000;
if (start_time != 0 && time < 0)
time_limit = 0;
Abort("You failed to get out alive...");
GetSystemFont().drawText(0, 0, time_limit - time);
start_time = 0;
Add start_count_down and stop_count_down into triggers of your choice...
Change the Abort in DrawTime to something useful..
Say it could create a boulder in your path at the exit (forcing you to quit) or it could drop a boulder ontop of you and kill you.
CreatePerson("boulder", "boulder.rss", true);
And then say you died using a text function or something...
Oh, finally you want:-
In the castle game I made for this tutorial, just press S to save where you are.
(It doesn't save what map your on because sphere doesn't have GetCurrentMap() yet!)
I think that's it for now!