Files
Superalgos/DesignSpace/Workspace/FunctionLibraries/SuperScripts.js
T
2020-02-19 19:17:28 +01:00

43 lines
1.3 KiB
JavaScript

function newSuperScriptsFunctions () {
thisObject = {
runSuperScript: runSuperScript
}
return thisObject
function runSuperScript (node, functionLibraryNodeCloning, functionLibraryUiObjectsFromNodes) {
let clone = functionLibraryNodeCloning.getNodeClone
function setup (templateClone, target) {
spawnPosition.x = target.payload.position.x
spawnPosition.y = target.payload.position.y
functionLibraryUiObjectsFromNodes.createUiObjectFromNode(templateClone, target, target)
}
/* Validations */
if (node.payload.parentNode === undefined) {
node.payload.uiObject.setErrorMessage('Super Action node needs a Parent Node.')
return
}
if (node.payload.referenceParent === undefined) {
node.payload.uiObject.setErrorMessage('Super Action node needs to reference a Master Script Node.')
return
}
if (node.payload.referenceParent.javascriptCode === undefined) {
node.payload.uiObject.setErrorMessage('Master Script Node needs to have a child Javascript Code Node.')
return
}
let superAction = node
let masterScript = node.payload.referenceParent
try {
eval(masterScript.javascriptCode.code)
} catch (err) {
superAction.payload.uiObject.setErrorMessage(err.message)
}
superAction.payload.uiObject.setValue('Execution Completed Successfully')
}
}