Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert all GUI code and raw Jass into vJass and cJass #1

Closed
AddisonG opened this issue Jul 3, 2015 · 2 comments
Closed

Convert all GUI code and raw Jass into vJass and cJass #1

AddisonG opened this issue Jul 3, 2015 · 2 comments

Comments

@AddisonG
Copy link
Owner

AddisonG commented Jul 3, 2015

I cannot put code here if it's not code. Therefore, I'll need to convert some of my simpler triggers into Jass, so that I can save it here.

Additionally, I need to ensure a style guide is followed for my code. I'll give a rough outline below:

// Includes at top of file
include "file.j"

// Globals should be declared at the highest level trigger that uses them.
globals
    force PLAYERS = CreateForce()
    location MAP_CENTER = Location(16384, 16384)
endglobals

// Note the function declaration. Use 'void' instead of 'nothing'
void selectUnit() {
    // Do not include the (implicit) keyword 'local'
    location spawnpoint = MAP_CENTER

    // Do not include the (implicit) keyword 'call'
    CreateUnitAtLoc(GetEnumPlayer(), 'h000', spawnpoint, GetRandomReal(0, 360))
    // This is cJass - remember to make use of { }
    if (GetLocalPlayer() == GetEnumPlayer()) {
        ClearSelection()
        SelectUnit(bj_lastCreatedUnit, true)
    }
}

// Function comments should always be included, even if just simple ones.
/**
 * Adds one to the number provided, then doubles it.
 * I could have done this by typing: "++subject*2"
 */
int addOneAndDouble(int subject) {
    subject++
    subject *= 2
    return subject
}
@AddisonG
Copy link
Owner Author

Progress made!

@AddisonG
Copy link
Owner Author

Note to self:

Before closing this, ensure that all globals are appropriately declared (Ideally above the method that uses them), and general code base is tidy. There should never again have to be a refactor once this is done.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant