Comparing version 0.0.0-prealpha to 0.0.1-prealpha
{ | ||
"name": "sb-util", | ||
"version": "0.0.0-prealpha", | ||
"version": "0.0.1-prealpha", | ||
"description": "Scratch blocks utilities: open and query Scratch blocks formats", | ||
@@ -5,0 +5,0 @@ "repository": { |
# Purpose | ||
This repo demonstrates a proof of concept for the .sb3 utility for Scratch. It is a naive Javascript implementation to illustrate the different ways a project.json can be queried to get insightful information about a Scratch project. | ||
# Documentation | ||
In depth documentation of the sbutil API can be found on Google Drive: [https://docs.google.com/document/d/1mL5r9CZH3Ru-vfs7T-8c53PO59IT2a7NpiIt3t24fMw](https://docs.google.com/document/d/1mL5r9CZH3Ru-vfs7T-8c53PO59IT2a7NpiIt3t24fMw) | ||
## Running the script | ||
@@ -8,0 +5,0 @@ ``` |
@@ -142,2 +142,33 @@ const jp = require('jsonpath'); | ||
} | ||
text(node = this.get('*')[0]) { | ||
console.log(node.get('opcode')) | ||
const nextAttr = node.get('next') | ||
const substacks = Object.entries(node.get('inputs')) | ||
.filter(([k,v]) => k.includes('SUBSTACK')).map(([k,v]) => [k.replace('SUBSTACK', ''), v]).sort((a,b) => { | ||
return b[0] < a[0]; | ||
}).map(([k,v]) => v[1]); | ||
// explore the substack if there | ||
if (substacks) { | ||
let index = 0; | ||
substacks.forEach(s => { | ||
if (index === 0) { | ||
console.log('if'); | ||
} else { | ||
console.log('else'); | ||
} | ||
const nextNode = this.get('*').filter(b => b.get('id') === s).pop(); | ||
this.text(nextNode); | ||
index++; | ||
}) | ||
} | ||
if (nextAttr === null) { | ||
return; | ||
} | ||
const nextNode = this.get('*').filter(b => b.get('id') === nextAttr).pop(); | ||
this.text(nextNode); | ||
} | ||
} | ||
@@ -205,2 +236,2 @@ | ||
let spriteOfBlock = sp.query('sprite block'); | ||
console.log(spriteOfBlock); | ||
spriteOfBlock.text(); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
7832
194
8