realXtend / tundra

realXtend Tundra SDK, a 3D virtual world application platform.
www.realxtend.org
Apache License 2.0
84 stars 70 forks source link

Add support for Lua or AngelScript scripting. #313

Open juj opened 12 years ago

juj commented 12 years ago

Due to dozens of problems and missing features related to QtScript correctness and performance, add support for creating in-world scripts with either Lua or AngelScript. (preferably both [tell me which is better afterwards {I am serious}]).

antont commented 12 years ago

i made the boilerplate for a Lua scripting module using QtLua a while ago, is uncommitted on my laptop at home - i could check it in the evening and push somewhere. qtlua seemed pleasant to work with so far at least, i've no idea how it performs in the c++ <-> lua conversions

for performance and other things can be a good idea to test the PythonQt thing we already have in and working, it at least reuses the qobject instances cleverly afaik

juj commented 12 years ago

For the remainder of this issue item, you may post all odd snippets which crash inside Qt, or silently fail, or similar. (you may also create a separate issue for them)

Here is one:

var v = float3.zero; v.x = 1; print(v); // Prints (0,0,0) print(float3.zero); // Prints (0,0,0)

Above v is initialized to be a reference of float3.zero. Because float3.zero is read-only (you can't make the zero vector non-zero), assigning to v is not allowed. However, QtScript will silently ignore the statement 'v.x = 1;' without issuing an error (which I think is a bug in QtScript itself).

To allow assigning v.x = 1;, the constant float3.zero should be made to behave like a value type, but it is not possible with QtScript (or JavaScript) (afaik).

erno commented 12 years ago

Pypy claims to have a safe Python sandbox: http://doc.pypy.org/en/latest/sandbox.html

juj commented 12 years ago

There is also an internal QtScript bug related to printing variables, which can crash the server, but I will not disclose that until the bug has been fixed inside Qt.

juj commented 12 years ago

Using Python for inworld scripts would require a) The ability to create separate script contexts per EC_Script component. b) Implement the support to use the script class mechanism for Python as well. c) Safe automatic teardown of script contexts. (can use a OnScriptDestroyed mechanism for those features that require C-like free()s) d) Implement several bindings to Python (i.e. issues #34, #35, #36, and related ones)

antont commented 12 years ago

Making static QtScript bindings for parts of Tundra might be a good thing -- and the possible performance improvement of that is easy to test, posted details of that and some other ideas in http://groups.google.com/group/realxtend-dev/browse_thread/thread/380c061b2e3b0042

juj commented 11 years ago

There now exist a bindings generator and an interop mechanism for MathGeoLib to Angelscript, available for testing here: https://dl.dropbox.com/u/40949268/emcc/MathGeoLibTestAS.html This code runs Angelscript in a web browser and contains the MathGeoLib library to play with.

juj commented 11 years ago

There is a work-in-progress integration branch of angelscript to Tundra at https://github.com/LudoCraft/Tundra/tree/angelscript

jonnenauha commented 11 years ago

Nice. This is quite welcome if gives perf gains. If Angescript can be ran on browser clients (like .js can) too thats a bonus.