Comments (4)
Thanks a lot for the super valuable feedback!
- AFAIK,
true ? 5
is actually an invalid statement because it has to be terminated with a semicolon in order to be parsed correctly. (Unless that changed by now; it was mentioned in an internal doc by the Minecraft team) - I've added a variant of the execute function that catches errors. We didn't have this in before because bridge. uses errors for validating MoLang scripts. I realize that this is not ideal for other use cases.
Math.pow(2, 2)
runs fine for me. Can you elaborate how the math functions are broken for you? :)
from molang.
I think a binary statement without semicolon should be valid. Not sure where they mentioned that it shouldn't, maybe you can point me to that. But I tested in-game and it worked fine, and the documentation mentions nothing about that.
Not sure why math doesn't work for me. I cloned the repository, installed dependencies, created a file with this content and ran it in Node:
const MoLang = require('.');
let n = MoLang.execute('Math.pow(2,2)');
console.log(n);
And it threw this error:
TypeError: this.name.eval(...) is not a function
at T.eval (C:\Users\Jannis\Documents\Development\MoLang\dist\main.cjs.js:1:8606)
at Object.exports.execute (C:\Users\Jannis\Documents\Development\MoLang\dist\main.cjs.js:1:17339)
at Object.<anonymous> (C:\Users\Jannis\Documents\Development\MoLang\test.js:2:16)
from molang.
- It was part of the first draft of the new MoLang features inside of #partner_molang. Since you can get it to work without it, I'll remove the check for the semicolon. That's a super easy fix.
- Oh, that's an extremely good catch. Thanks, will be fixed in a sec
👍
from molang.
Thanks again for the feedback. All of it should be addressed in v1.6.1! :)
Please note that I've changed the API surface to be a class in order to support better handling of execution environments and improve performance even further. Therefore, you'll need to change the JS accordingly:
import { MoLang } from "molang"
const myMolang = new MoLang({ /** Variables, queries etc. here */ }, { /** Settings here */ })
let n = myMolang.execute('Math.pow(2,2)');
console.log(n);
// Or without errors
let n = myMolang.executeAndCatch('Math.pow(2,2)');
console.log(n);
from molang.
Related Issues (4)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from molang.