2

I'm building an MMO using Node.js, and I'd like some scripters from my team to create scripts (duh) for bosses and other scripted objects. My first thought was to have a folder on the server where people can upload javascript files and let node.js automatically read and parse every script in the directory, but I don't want them to be able to execute process.exit() for example, or other hazardous stuff.

Is there a solution that lets me control what functions the scripters are able to call?

2 Answers 2

4

You can control what functions are they unable to call with vm module.

For example,

vm.runInNewContext(userCode, {
    require: null,
    process: null,
    someFunc: function (x) { return x+1 },
    someData: { abc: 'def' }
});
Sign up to request clarification or add additional context in comments.

Comments

1

Will javascript work as scripting language. I guess it should.
so, I think vm.runInNewContext is might be all you need. Have a look at http://nodejs.org/docs/latest/api/vm.html

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.