1. If you are going to register on XLNation, please make sure you do not use a proxy server.
    If you use a proxy server your registration will most likely get blocked due to spammers and hackers using proxy servers to hide their real IP address.

    If your using your home or work IP address and have not received your registration email, check your spam folder.
    PLEASE DO NOT ASK TO HAVE YOUR ACCOUNT DELETED IF YOU HAVE POSTED IN THE FORUM! If so we do not delete accounts due to the mess it can make on the forum.
    Dismiss Notice
  2. Please see the following thread for more information
    XLN's future is looking bad

Tutorial using luac (lua's byte code compiler)

using luac (lua's byte code compiler) to useful things!!

  1. XL Nation Staff
    luac lua's byte code compiler can be used to reduce the time it takes to load lua code, to reduce memory usage and more!

    each time the game is started the lua source code is loaded and compiled into byte code that lua can then run. that loading into memory, compiling, ect takes time and memory.

    as users have more and more mods that load time, compile time, and memory foot print becomes significant. and people hate waiting!

    luac does this by precompiling the lua source code into byte code and removing debugging information

    to start you have to download and install lua 5.1.x (not 5.2.x)
    http://lua-users.org/wiki/LuaBinaries

    once that is dont its easy to use luac

    just open command prompt and enter:



    luac -o <filename>.luac -s <filename>.lua



    where is the name of the lua source code file that you would like to compile to byte code.

    the -o option tells luac that you would like specify the name of the output file

    and the -s option tells luac that you would not like to generate any debugging information, thus reducing the size of the resultant lua byte code and resulting in both faster load times and reduced memory usage!

    for example
    where C:\dev\citiesxl\src\cxl_enhanced_mod\Data\interface\panels\ingame\ingame.lua contains the lua source code i would like luac to compile to lua byte code
    and where C:\dev\citiesxl\release\cxl_enhanced_mod\Data\interface\panels\ingame\ingame.lua contains the lua byte code that i would like to release with my mod

    an additional benefit of using luac is that you will no longer be releasing the source code to your mods. people who download them will only be getting the byte code. which protects your intellectual property. this does not mean that it is completely protected since byte code can easily be reconstitute as source code using decompiler. and this does not mean that mod developers cant still release a source code version of the mod for other modders, but giving just the byte code to players makes sense since it will load faster, use less memory and run slightly faster.

    just so that everyone knows i tested the above to see if it would work by unpacking all the existing pak files, recompiling them all and then replacing the lua source code in the pak files with the luac byte code files (with same name) and while the game did not run any faster, its basically the same byte code, the game loaded up significantly faster and used more than 30mb less memory!

    now i am not saying you would like to do that. perhaps focus should consider doing this and then making the source code available to modders as a zip file that they put someone on their modding website.

    if you would like to learn more here is the man page for luac
    http://www.lua.org/manual/4.0/luac.html

    anyways here is my first tutorial. hope it helps mod developers by offering new choices and options.
    AlexArtAndros likes this.