-
Notifications
You must be signed in to change notification settings - Fork 2
Lua compatibily
There are some limitations in the WebNCL support for Lua scripts. Some of those limitations will be addressed in future versions of WebNCL; other limitations are more complex to solve given javascript's restrictions or the approach used for running Lua script.
In this page are listed limitations and workarounds that can be used to solve then.
For a description of event module, see this page. (in portuguese).
Only the events of class tcp are not implemented yet.
For a description of canvas module, see this page. (in portuguese).
All the methods of canvas module presented in the page above are implemented.
All the methods of persistent module are implemented.
All the methods of settings module are implemented, but not all the possible settings.
Loading images and fonts in Lua Scripts is a synchronous task, but it is asynchronous in javascript. Because of this difference, it may be necessary preloading the used resources before execute the Lua scripts.
For preform the preloading, we recommend the use of PxLoader. It has support for preloading images, videos and audios. For fonts, we developed a plug-in for PxLoader.
See a sample of how to use PxLoader.
var myPlayer = new WebNclPlayer("sample/sample-control-lua.ncl","myPlayer");
var loader = new PxLoader();
loader.addImage('test_lua/image1.png');
loader.addImage('test_lua/image2.png');
loader.addFont('garamond','sample/EBGaramond08-Regular.ttf');
loader.addFont('times','sample/times-Regular.ttf');
loader.addCompletionListener(
function() {
myPlayer.start();
});
loader.start();Currently the WebNCL does not support lua require primitive.
Given the single thread characteristic of javascript language, WebNCL does not support Lua Coroutine.
Although you can simulate coroutines with timers or other mechanism easily.
Here are some important differences between the Lua C and the current implementation of lua.js:
- A 'NaN' value is equivalment to false in Lua C, but is a true for lua.js