Update readme
This commit is contained in:
commit
2664e47a9c
|
@ -0,0 +1,25 @@
|
|||
# Bitsy Bundler!
|
||||
|
||||
This is a tool that lets you download a bunch of hack/plugin files for the game engine [Bitsy](https://ledoux.itch.io/bitsy) to extend the engine's functionality. It compiles them into a single js file that you can easily include in your game HTML file without making it, like, really really long.
|
||||
|
||||
System Requirements:
|
||||
|
||||
* Some relatively recent version of PHP, because I could not tell you what happens if you use like PHP 4 or something. If you don't have a version of PHP, [look at this guide](https://www.php.net/manual/en/install.php).
|
||||
* A command line program you like
|
||||
* A text editor I guess?
|
||||
|
||||
## How to use
|
||||
|
||||
1. Download Bitsy Bundler (either from source control or as a zip file), and put the files into your project folder.
|
||||
2. Edit your hacks.json file:
|
||||
* Add any additional hack repositories you might be drawing from, in the format user/repo/path/to/folder.
|
||||
* If you have any local hack files, change the "local" value to be the relative path to that directory.
|
||||
* Add the names of any hack files (minus the "js") to the "hacks" array. You can also add full-on URLs in here if you have hacks from other sources.
|
||||
3. Run `php bundler.php` from your project folder on the command line.
|
||||
4. This will generate a hacks.js file, alert you to any issues you might have encountered (missing sources, for example), and also give you a copy-paste line to put into your Bitsy HTML file, if you haven't already.
|
||||
|
||||
Anyway that's it. This is probably still a little arcane for non-programmers, potentially, so I'm open to any suggestions as far as making it more user-friendly/adding more options/etc.
|
||||
|
||||
If you really don't want to deal with a terminal interface, there's [Borksy](https://ayolland.itch.io/borksy)! This is just for power users and my highly specific desire to easily add and swap out hacks without having to generate a new game template.
|
||||
|
||||
If you get use out of this, obviously it's free! But on account of I'm presently freelance I appreciate tips, either via itch.io purchase or via [ko-fi](https://ko-fi.com/veryroundbird).
|
|
@ -0,0 +1,68 @@
|
|||
<?php
|
||||
error_reporting(E_ALL);
|
||||
echo "Starting hack bundler...\n";
|
||||
echo "Getting hacks file...\n";
|
||||
$hacks_file = file_get_contents('hacks.json');
|
||||
$time_start = microtime(true);
|
||||
if (!$hacks_file) {
|
||||
echo "hacks.json file not found. creating file.";
|
||||
// create the hacks file
|
||||
$hacks_file = file_get_contents('hacks.json');
|
||||
}
|
||||
|
||||
$hacks = json_decode($hacks_file);
|
||||
if (!$hacks) {
|
||||
echo "hacks.json file malformed or improperly formatted. you may need to delete it and re-create it.";
|
||||
die(1);
|
||||
}
|
||||
|
||||
$hacks_accumulator = "";
|
||||
|
||||
foreach ($hacks->hacks as $hack) {
|
||||
echo "Getting hack {$hack}...\n";
|
||||
preg_match('/https:\/\//', $hack, $output_match);
|
||||
if (count($output_match) > 0) {
|
||||
// it's a url, so just curl it
|
||||
$handle = curl_init($hack);
|
||||
curl_setopt($handle, CURLOPT_RETURNTRANSFER, 1);
|
||||
$ret = curl_exec($handle);
|
||||
if (!$ret) {
|
||||
echo `WARNING: Error getting {$hack} from URL. Hack will be skipped.\n`;
|
||||
} else {
|
||||
$hacks_accumulator .= $ret."\n\n";
|
||||
}
|
||||
} else {
|
||||
// first check sources
|
||||
$found = false;
|
||||
foreach ($hacks->sources as $source) {
|
||||
$handle = curl_init('https://cdn.jsdelivr.net/gh/'.$source.'/'.$hack.'.js');
|
||||
curl_setopt($handle, CURLOPT_RETURNTRANSFER, 1);
|
||||
$ret = curl_exec($handle);
|
||||
if ($ret) {
|
||||
$hacks_accumulator .= $ret."\n\n";
|
||||
$found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!$found) {
|
||||
echo `{$hack} not found in remote libraries; checking local.\n`;
|
||||
// check in local hacks folder
|
||||
$hack_content = file_get_contents($hacks->local.'/'.$hack.'.js');
|
||||
if (!$hack_content) {
|
||||
echo `WARNING: Hack {$hack} skipped; not found in remote sources or local.\n`;
|
||||
} else {
|
||||
$hacks_accumulator .= $hack_content."\n\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
echo "Writing to file...\n";
|
||||
file_put_contents('hacks.js', $hacks_accumulator);
|
||||
|
||||
$time_end = microtime(true);
|
||||
$totaltime = number_format($time_end - $time_start, 2, ".", ",");
|
||||
$hackcount = count($hacks->hacks);
|
||||
echo "{$hackcount} hacks processed in {$totaltime}ms.\n";
|
||||
echo "Add the following to your Bitsy HTML file, just above the body tag, if you haven't already:\n";
|
||||
echo '<script src="hacks.js" type="text/javascript"></script>';
|
|
@ -0,0 +1,31 @@
|
|||
{
|
||||
"sources": [
|
||||
"seleb/bitsy-hacks/dist"
|
||||
],
|
||||
"local": "hacks",
|
||||
"hacks": [
|
||||
"avatar-by-room",
|
||||
"backdrops",
|
||||
"bitsymuse",
|
||||
"character-portraits",
|
||||
"close-on-ending",
|
||||
"dialog-choices",
|
||||
"dialog-jump",
|
||||
"dialog-pause",
|
||||
"dynamic-background",
|
||||
"edit-image-from-dialog",
|
||||
"edit-player-from-dialog",
|
||||
"edit-room-from-dialog",
|
||||
"end-from-dialog",
|
||||
"exit-from-dialog",
|
||||
"external-game-data",
|
||||
"favicon-from-sprite",
|
||||
"follower",
|
||||
"gamepad-input",
|
||||
"long-dialog",
|
||||
"opaque-tiles",
|
||||
"paragraph-break",
|
||||
"permanent-items",
|
||||
"save"
|
||||
]
|
||||
}
|
Loading…
Reference in New Issue