Skip to content

Instantly share code, notes, and snippets.

@HelloWorld017
Last active April 10, 2017 02:51
Show Gist options
  • Save HelloWorld017/d173812ba60d93ccb8c845fd94051ecc to your computer and use it in GitHub Desktop.
Save HelloWorld017/d173812ba60d93ccb8c845fd94051ecc to your computer and use it in GitHub Desktop.
JS Evaluate for scratch
new (function() {
var ext = this;
ext._shutdown = function() {};
ext._getStatus = function() {
return {status: 2, msg: 'Ready'};
};
ext.eval = function(str){
return eval(str);
};
ext.evalWithValue = function(value, str){
return eval(str);
};
var descriptor = {
blocks: [
['r', 'eval( %s )', 'eval', 'Math.random()'],
['r', 'value = %s ; %s', 'evalWithValue', '10', 'console.log(value)']
]
};
// Register the extension
ScratchExtensions.register('JS Eval Extension', descriptor, ext);
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment