Jump to content

Skhorn

Community Members
  • Posts

    335
  • Joined

  • Last visited

  • Days Won

    10

Posts posted by Skhorn

  1. Skhorn, you should post once more (so you can PM) and get a copy of our signature in your signature.

    Thanks, i was wondering how to send a PM.

    If you know Java then you might find JavaScript as easy as it is. JavaScript is not strongly typed.

    Here a bad CrashCurs Java -> JavaScript:

    int numberOfCalls = 0;double number = 0.0;String arrayOfChars = "zeichenkette";public int resolvePlayerId(PlayerData[] playerDatas, String name){    ++numberOfCalls;    for (int i; i < playerDatas.length; ++i)        if (playerDatas[i].name == name)            return playerDatas[i].playerId;}
    -->

    var numberOfCalls = 0;var number = 0.0;var arrayOfChars = "zeichenkette";function resolvePlayerId(playerDatas, name){    ++numberOfCalls; //<-- using global variable    for (var i; i < playerDatas.length; ++i)        if (playerDatas[i].name === name) // <-- triple = to check for the same type too. Otherwise "1" and 1 would resolve to True.            return playerDatas[i].playerId;}
    In JavaScript you can also write:

    var f = function(data){    // ...}
    or:

    var object = {};var array = [];object["my_new_key"] = function() {    // append a reference to the object to the array, which makes no sense at all as at the end each array entry contains the same value.    array[array.length] = object;};// execute the function:object.my_new_key();
    JavaScript is easier and way more error-tolerant than Java.

    You can still program JavaScript like if it was Java. You don't need to use the special features of JavaScript, but you need to use "var" instead of "int", "double", "type", "Class".

    Instead of public int you use function.

    A function can store values (like a class / instance):

    function MyClass(initParameter1){    var privateVar = 0;    this.defaultParameter = initParameter1;    this.method = function()    {        ++privateVar;    }    this.getPrivateVar = function()    {        return privateVar;    }}var myObj = MyClass("default");warn(myObj.defaultParameter);  // output "default" as a 0AD ingame warning.warn(myObj.getPrivateVar());    // prints 0myObj.method();warn(myObj.getPrivateVar());   // prints 1

    After that, Tereisias' instructions might be helpful to get full force into 0AD AI development (to assist mimo): http://www.wildfiregames.com/forum/index.php?showtopic=18375&p=286844

    It assumes Linux + Git. But you might want to read http://trac.wildfiregames.com/wiki/BuildInstructions#Getting_the_code .

    JS is dynamically typed... dont know if thats the right name, as in python, a variable can take any value in different lines.

    And you just answered another question i had, the Linux + Git.

    I'll get into it.

    Thanks

  2. I got a copy 2 months ago, from the svn repository, just to try out dudes on walls xD.

    Im studying systems engineering.

    Now that thamlett mentions the multilingual thing... and i know here is not the place to say it, but if someone wants to learns spanish or teach me german or russian or another language, i'll be cool :D

  3. Hi,

    I would like to join as a programmer, researcher, tester or anything i could help with , i only know some python and java, but im willing to learn. If someone can point me to where to learn js --- documentation, i'll be glad.

    Im a student, cant say i have all the time, but i can spend some time.

    Sorry for my english.

×
×
  • Create New...