cJass2Lua - Powerfull cJass converter

Level 3
Joined
Jan 16, 2013
Messages
11
Warcraft III Reforged brought us lua scripting, but still a lot of map makers for WC3 are using cJass. Just because C-style syntax rules. Unfortunately cJass extension is unsupported for Reforged and who knows how it will be. Lua is more efficient, useful and simple for game development. But a lot of projects are still on cJass and no way to convert them to Lua. Editor without cJass extension does not perceive this code. Re-writing code manually to Lua could take a lot of time, nobody wants to waste time on it. This tool comes to solve this problem. cjass2lua tool can easily convert cJass to readable Lua code, it will help you to upgrade your map by modern map development patterns.

Features
  • Analyzing and syntax checking cJass code
  • Producing .lua file with converted code of your cJass code
  • Single file conversion
  • Massive folder-to-folder conversion
  • Advanced logging of application
  • Opportunity to implement output for any other script language
  • 100% readable code formatting
  • Saving comments, comment positions and new lines, function and variable names, spaces in expressions
  • Config file with application's settings
  • Minimalistic and simple GUI interface
  • Command line interface
Unsupported features
  • Analyzing classes/structures and converting them to Lua meta table implementation
  • JASS/vJASS Syntax
  • Pre-processor directives
  • Macroses. Only constants, function and variable shorters. Macroses are translated into global variables.
Example:

Input cJass code:

Code:
define {
    var1 = 245
    example = 2.46
}

define
    SOMETHING = 200
    EXAMPLE_STRING = "sfgsdfgsdfg"
    RAW_CODE = 'A0BX'
enddefine

globals
    int lel = 56;
    bool Illidan = false;
    //void NOTHING = NULL;
    string Arthas = "LichKing";
    player p = null;
    float value;
endglobals

int testMePlease(player p, unit u, bool flag)
{
    int integer1, integer2, integer3 = 35, integer4 = 21, wtf[], wtf35 = GetSuperMegaInt(a, b, c);
    local float pi = 3.14
    integer1 = someNotVisibleFunction.evaluate();
    int abilityCode = 'A0F2';
    string str = "Hello world!";

    timer t = CreateTimer()
    call TimerStart(t, 0.1, true, lambda void ()
    {
        timer t = GetExpiredTimer();
        int someComplicatedExpr = (integer1 / 2) * wtf35 + wtf[2] * g_Matrix[1][5] - FunctionOne(FunctionTwo(), arg25)
        SeparatedLinesCall(a, b,
        c
        , d, e, f);

        DestroyTimer(t);
    });
    //Comment 1

    if (a == b || b != 0)
    {
        Call1();
    }
    elseif(flag != 4.56)
    {
        Call2(); //Comment 2
    }
    else
    {
        int eee = 0;
        eee += wtf35;
        int i = 0;
        while (i < 25)
        {
            doSomething(a, b, i);
            i++;
        }
    }

    return integer24 * (call2(a / 3));
}

Code:
var1 = 245
example = 2.46
SOMETHING = 200
EXAMPLE_STRING = "sfgsdfgsdfg"
RAW_CODE = 'A0BX'
lel = 56
Illidan = false
Arthas = "LichKing"
-- player p
-- float value


-- void NOTHING = NULL;
function testMePlease(p, u, flag)
    local integer3, integer4, wtf, wtf35, integer1, integer2 = 35, 21, {}, GetSuperMegaInt(a, b, c)
    local pi = 3.14
    integer1 = someNotVisibleFunction()
    local abilityCode = FourCC('A0F2')
    local str = "Hello world!"
 
    local t = CreateTimer()
    TimerStart(t, 0.1, true, function ()
        local t = GetExpiredTimer()
        local someComplicatedExpr = (integer1 / 2) * wtf35 + wtf[2] * g_Matrix[1][5] - FunctionOne(FunctionTwo(), arg25)
        SeparatedLinesCall(a, b,
        c
        , d, e, f)
    
        DestroyTimer(t)
    end)
 
    -- Comment 1
    if a == b or b ~= 0 then
        Call1()
    elseif flag ~= 4.56 then
        Call2()    -- Comment 2
    else
        local eee = 0
        eee = eee + wtf35
        local i = 0
        while i < 25 do
            doSomething(a, b, i)
            i = i + 1
        end
    end
 
    return integer24 * (call2(a / 3))
end

Attention:
  • To convert code to lua you must be shure that:
  • Your code is 100% correct
  • You have no objects or classes/structures
  • You have no JASS syntax (as loop/andloop, if/else and function definition). But some vJass features added (; is not necessary, set, local, call keywords are parsed correctly
  • Read logs if something foes wrong, this application leaves cjass2lua.log file with all it's actions and possible problems. Everything should be fine if you have no warnings.

Source code and updates on github: fullmetal-a/cjass2lua
 

Attachments

  • cJass2Lua_v1.01_x86.zip
    300.5 KB · Views: 51
  • cJass2Lua_v1.01_x64.zip
    352 KB · Views: 62

Wrda

Spell Reviewer
Level 23
Joined
Nov 18, 2012
Messages
1,731
Honestly it seems silly that you write something acoording to a certain syntax with a corresponding semantics, but you want the semantic to be different. It's like, I don't what I'm looking at, looks like vjass, lua and C# at same time, all in one package. While your intentions are nice, I think your effort and dedication could be invested for something else.
 
Top