sparkscript
Version:
DiamondFire for Javascript.
65 lines (49 loc) • 2.48 kB
Markdown
# DiamondFire library
__Simple to use DiamondFire library for Javascript.__
__Check out [DiamondFire](https://mcdiamondfire.com), its pretty cool.__
__Manual template manipulation guide by Owen [here](https://mcdiamondfire.com/threads/code-template-manipulation.51/)__
[](https://github.com/UserUNP/sparkscript/actions/workflows/sparkscript.yml)
[](https://github.com/UserUNP/sparkscript/actions/workflows/codeql.yml)
[](https://npmjs.org/package/sparkscript)
***Warning***: *No stable version yet.. everything might flop and/or change*
Example: *for current git build*
```javascript
// import the quick editor
// import df from "sparkscript";
const df = require("sparkscript").default;
const template = df("Test template", (e, s) => {
// e short for "editor"
// s short for "settings"
e.defAction("giveItems", (/* args */) => {
e.player.action("SetHotbar", e.mc("cod", "§b§l<-§c§o killer fish §b§l->"), e.mc("bow", "§b§l<-§c§o le bow §b§l->"))
//* you can use & for other things. use § for color codes.
});
//* you can use .setTarget() to specify the player to target. you can also chain it amongst other functions
//* ex:
// const funnyAction = e.player.action("DoAFlip").setTarget("Default")
// funnyAction.setInverted(true).setAction("NOTAFlip)
e.player.event("Join");
e.action.giveItems();
e.player.event("Respawn");
e.action.giveItems();
});
const code = template.export();
console.log(code.compressed);
```
Key features:
\> Read from template data with `.from( )` function.
\> ~~Read & compile from Spark file, buffer or string.~~ **_till spkc v2 gets an official release._**
\> Easy to use template editor.
## Actiondump
You might need to specify the actiondump using the `setActionDump` function that's in default export.
Or use the `codeDump` file that exports all actiondump related functions into a default object, simply import the file:
`const codeDump = require("sparkscript/core/codeDump");` or `import codeDump from "sparkscript/core/codeDump";`
# Build from source
You can use either `npm` or `yarn` for this.
```sh
mkdir sparkscript
cd sparkscript
git clone https://github.com/UserUNP/sparkscript .
npm install
npm run build
```