Storage
The storage is an object in which we can put everything we want to save when a player saves the game.
We have to create a property where the player can store his data in it. So in storage.js we start with...
var storage = {
player: { // add property
name: "" // add placeholder
}
}
// Syntax
var storage = { // object
property1: { // property of object
placeholder1: 0, // integer of property
placeholder2: "" // string of property
}
}If we now want to get the name after saving one in there, this would look like this in the script.js.
storage.player.name = "Monogatari"; // example for saving a name
"{{player.name}} is a visual novel engine." // example for display the nameTo offer more possibilities in the game and to have a simpler overview in the storage file, you can create as many properties as you want, just make sure to use a comma before adding a property. Here is an example...
var storage = {
player_info: {
name: "",
age: "",
city: ""
},
player_stats: {
hp: 100,
mp: 100,
inventory: {
gold: 1000,
iron: 10
}
}
}Which can be accessed as follows (examples)...
If you want to see an example of the stat system (created with storage.js), click me.
Last updated
Was this helpful?