lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Jason Neufeld a écrit :
Thanks for all the suggestions so far!

As far as the AVM2 suggestion, I think it's a great idea, I actually
had the same suggestion from the author of tinypy when I was
considering using his system. However, the problem in this case is the
domain of the problem. The game system that I'm building is basically
going to allow for custom user scripting that will be run from the
game engine, but in a sense it needs to be heavily sandboxed. For
example, a script could be attached to a particular object and tell it
how to move around and interact with the world around it, but it
should have no privileges beyond whatever built-in functions it has
been given. I think a direct bytecode compilation would be great if
speed were the only concern, but essentially what's going to happen
here is that the Lua code will be compiled serverside and then
executed from the client as part of the customizable aspects of the
game script. Because of the security and the modular nature of the
engine it seems like having some sort of VM running the scripts is the
best solution for my particular problem. I'd love to hear more
suggestions if you think there's a way around the problem that would
allow me to safely use AVM2 bytecode, because I know it would be
faster and much more efficient.

You could use hxASM (http://haxe.org/com/libs/hxasm)

It enables you to generate AVM2 bytecode at runtime, either on the client side in Flash, or on the server side / commandline using NekoVM.

This way you could translate your Lua bytecode to AVM2 one on-the-fly by doing appropriate checks for sandbox restrictions.

Also, using haXe to write your VM for Flash9 would surely help since there are many optimizations and it runs faster than AS3.

Hope that helps,
Nicolas