persist.js is a framework for the Sphere RPG engine that lets you store persistent data and code with persons and maps. It can be used for very powerful techniques, such as abstracting common person behaviours, and organising code.
RequireScript("persist.js"); function game() { persist.init(); // ... }
/** * This will greet the player when they enter the map, * and let the person named "Billy" say how many times * the player has spoken to them. */ ({ visited: false, enter: function (self) { if (!self.visited) { Say("Welcome to " + GetCurrentMap() + "!"); self.visited = true; } }, Billy: { times: 0, talk: function (self) { self.times += 1; Say("Hi! We've spoken " + self.times + " before."); }, }, })