Download src/util/javascript-container.js from soiz1/penguinmod-vm-prain: direct link, hf CLI and curl.
- Browser
- Download file 1.39 kB
-
https://huggingface.co/datasets/soiz1/penguinmod-vm-prain/resolve/main/src/util/javascript-container.js
- Command line
-
hf download hf://datasets/soiz1/penguinmod-vm-prain/src/util/javascript-container.js
-
curl -L -o javascript-container.js https://huggingface.co/datasets/soiz1/penguinmod-vm-prain/resolve/main/src/util/javascript-container.js
1.39 kB
| const rotationStyleOptions = [ | |
| 'left-right', | |
| 'don\'t rotate', | |
| 'all around' | |
| ]; | |
| class execute { | |
| constructor (funcText, target, runtime) { | |
| const thisData = this.getThisFuncs(target, runtime); | |
| thisData.mySelf = new Function(funcText); | |
| } | |
| getThisFuncs (target, runtime) { | |
| // all of the functions accessed by `this` | |
| // must have there internal vars defined externaly | |
| // so that the code can not access nor edit them | |
| const thisFuncs = { | |
| goto: target.setXY, | |
| set xPosition (newPos) { | |
| target.setXY(newPos, target.y); | |
| }, | |
| set yPosition (newPos) { | |
| target.setXY(target.x, newPos); | |
| }, | |
| get xPosition () { | |
| return target.x; | |
| }, | |
| get yPosition () { | |
| return target.y; | |
| }, | |
| set direction (newDir) { | |
| target.setDirection(newDir); | |
| }, | |
| get direction () { | |
| return target.direction; | |
| }, | |
| set rotationStyle (style) { | |
| if (!rotationStyleOptions.includes(style)) { | |
| throw new Error(`invalid style: ${style}`); | |
| } | |
| target.setRotationStyle(style); | |
| } | |
| }; | |
| return thisFuncs; | |
| } | |
| } | |
| module.exports = execute; | |