matt-attack / jetscript Goto Github PK
View Code? Open in Web Editor NEWA simple scripting language for C++
License: MIT License
A simple scripting language for C++
License: MIT License
When you add negative function parameter to a script command, I lost some values in c++. Here's an example :
I have a script command, and second parameter of that command is negative number(-100).
effect_move("bat",-100,120,6);
The output returns first parameter, which is a string as number, same as second parameter.
(*_ScriptContext)["effect_move"] = [](Jet::JetContext* context, Jet::Value* arguments, int numarguments)
{
Jet::Value a = arguments[0]; // Number , -100 <- Lost string value
Jet::Value b = arguments[1]; // Number , -100
Jet::Value c = arguments[2]; // Number , 120
Jet::Value d = arguments[3]; // Number , 6
};
But when you use negative number as variable(num), everything works ok.
num = -100;
effect_move("bat",num,120,6);
(*_ScriptContext)["effect_move"] = [](Jet::JetContext* context, Jet::Value* arguments, int numarguments)
{
Jet::Value a = arguments[0]; // String, "bat" <- OK
Jet::Value b = arguments[1]; // Number , -100
Jet::Value c = arguments[2]; // Number , 120
Jet::Value d = arguments[3]; // Number , 6
};
ps. keep up the good work, this scripting language rocks !
I want to call script function and pass parameter to it, but it returns Null . I don't know if my JetContext call is wrong, so I hope this can be resolved. Here's example from my test :
Call from c++ :
// Don't know if this is a right way to pass parameters to script function
_ScriptContext->Call("onUpdate", new Jet::Value(dt),1); // dt is float
Script :
fun onUpdate(delta)
{
print(delta);
}
Return in console : Null
Thanks in advance
Currently dies with
Jet Language Console:
jetscript: malloc.c:2394: sysmalloc: Assertion `(old_top == initial_top (av) && old_size == 0) || ((unsigned long) (old_size) >= MINSIZE && prev_inuse (old_top) && ((unsigned long) old_end & (pagesize - 1)) == 0)' failed.
Aborted
Need to only include close instructions when needed.
Throwing a non-Jet exception during execution of a native function is not handled correctly.
Is there a way to set/get global script variables from c++ by name ? I've to get JetContext variables but I don't see where I can do that. It would be great if there is a mehod for setting/getting variable from c++, something like :
class JetContext
void addVariable(string name,Jet::Value Value);
Jet::Value getVariable(name);
Maybe there is a way but I can't figure it out from source :(
Thanks in advance
ps. I'm using jet scripting for a small game that I'm about to make, and this is realy nice because syntax is more like squirrel script (don't like lua syntax much ), but easier to setup,bind and run than squirrel script. So thanks for your efforts ๐
I really like this scripting language, this is exactly what i need for my project, so thanks for sharing. I have one question : Will there be possible to call from script to c++ ? Thanks in advance...
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.