Thanks Alpha Systems for that.
Click Save and Exit and wait until you will be back to the main menu.
- Updated "Response server simulator" now simulator allows you to inject data.js files
- Toolkit update, now you can load your own data.js modifications using simple
game.loadData(src)
function - Toolkit
game.saveCache(__dirname,files)
method for storing files for offline play - Toolkit showcase modification
- Restore c2runtime.js and data.js to original source code
- Add mods support without changing original files
- Mod selection from list
- Add server response simulator as mod
- Add working in-game map mod
- Update save editor UI & add more features
- Use toolkit.js to create an in-game panel that allows advanced game controls
- Creating helpers for better game control and easier creation of mods
Reload the page
- Open the game
- If you want to preserve your save
2.1. Enable theSave exporter & importer
mod
2.2. Export your save - Open site information (top left corner near the url)
- Go to Site settings
- Click Delete data
- Reload the game and import your save
If you want to create your own mod, create javascript file in mods/ directory, for example: mods/my-mod/my-mod.js
Now you must to add exported install function:
export function install(){
}
Now you can add some logic, for example I tried to add listener for buttons in-game that open links, and print in console.log what they want to open:
export function install(){
const original_open=window.open;
window.open=function(url, target, windowFeatures){
console.log(url,target,windowFeatures);
original_open(url,target,windowFeatures);
}
}
Now you need to modify mods.json, add your new mod to list:
{
"mods":[
// Other mods:
{...},
// Your mod:
{
"name":"Example mod",
"description":"Example description",
"script":"example-script",
"version":"1.0.0"
}
]
}
Now you can start the server, e.g. via NodeJS http-server and run the game:
Below is an simple example of loading a custom data.js file:
import { game } from "../toolkit.js";
const __dirname=import.meta.url.split("/").splice(0,import.meta.url.split("/").length-1).join("/");
const offlineFiles=[
"assets/image.png",
"assets/audio.ogg"
];
export async function install(){
await game.loadData(`${__dirname}/custom-data.js`);
await game.saveCache(__dirname,offlineFiles);
}
mods/
└── before-dayz/
├── before-dayz.js
├── custom-data.js
└── assets/
├── image.png
└── audio.ogg
All data.js modifications are saved to the browser memory, so offline play is possible