Дома на Острове 2: код из Studio перенесён в src и соединён с GameServer/FishingClient
This commit is contained in:
1 parent
a9bc4207cb
commit
0fe8bd35a0
8 files changed
+2032
-4
No files matched your search
@@ -0,0 +1,36 @@
|
||||
// Dumps every script in a .rbxlx (with its full instance path) into a folder,
|
||||
// so place scripts can be compared with src/.
|
||||
// usage: node tools/dump-place-scripts.js place.rbxlx outDir
|
||||
'use strict';
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
|
||||
const [,, inP, outDir] = process.argv;
|
||||
const text = fs.readFileSync(inP, 'latin1');
|
||||
const NAME_RE = /<string name="Name">([^<]*)<\/string>/;
|
||||
const TOKEN_RE = /<Item class="([^"]+)" referent="[^"]+">|<\/Item>/g;
|
||||
const stack = [];
|
||||
const seen = new Map();
|
||||
let m;
|
||||
fs.mkdirSync(outDir, { recursive: true });
|
||||
while ((m = TOKEN_RE.exec(text))) {
|
||||
if (m[0] === '</Item>') { stack.pop(); continue; }
|
||||
const cls = m[1];
|
||||
const ps = text.indexOf('<Properties>', m.index);
|
||||
const pe = text.indexOf('</Properties>', ps);
|
||||
const props = text.slice(ps, pe);
|
||||
const nm = NAME_RE.exec(props.replace(/<!\[CDATA\[[\s\S]*?\]\]>/g, ''));
|
||||
const name = nm ? Buffer.from(nm[1], 'latin1').toString('utf8') : '(' + cls + ')';
|
||||
stack.push(name);
|
||||
if (cls === 'Script' || cls === 'LocalScript' || cls === 'ModuleScript') {
|
||||
const sm = /<ProtectedString name="Source"><!\[CDATA\[([\s\S]*?)\]\]><\/ProtectedString>/.exec(props)
|
||||
|| /<ProtectedString name="Source">([\s\S]*?)<\/ProtectedString>/.exec(props);
|
||||
const src = sm ? Buffer.from(sm[1], 'latin1').toString('utf8') : '';
|
||||
let rel = stack.join('__').replace(/[\\/:*?"<>|]/g, '_') + '.' + cls + '.lua';
|
||||
const n = (seen.get(rel) || 0) + 1; seen.set(rel, n);
|
||||
if (n > 1) rel = rel.replace(/\.lua$/, '.dup' + n + '.lua');
|
||||
fs.writeFileSync(path.join(outDir, rel), src);
|
||||
}
|
||||
TOKEN_RE.lastIndex = pe;
|
||||
}
|
||||
console.log('dumped', [...seen.values()].reduce((a, b) => a + b, 0), 'scripts to', outDir);
|
||||
Reference in new issue
Block a user