Фэндом


Stub.png Эта статья не переведена до конца. Пожалуйста помогите нам доперевести ее.
Спасибо!

Back
This page will teach you how you should layout and format your code in such a way that it makes it easily understandable by any one who is looking at your code, having downloaded your expression, or offering help to you.


if(this){that} Править

Note: Some of this applies to while loops too.
Ok, so, let us begin.

use "if()" or "if ()", depending on personal preference.

and use blank lines to hint at blocks in the code (preferably with a comment as well)
for instance, after you've calculated all your forces and will apply them, add an empty line
to indicate that "this is something different".

and please use spaces between operations, trying to make them as compact and space-less as possible
only makes them impossible to read.

if statements check to see if the code in (...) is true before running the part in {...},
(...) is true when it is not equal to nil or 0.
for one statement in an if-statement
if (...) {...}
if (A) {B = 0}
if (!A & C > 2) {B = 0, C = 2}
for multiple statements in an if-statement
if (...) {
    ...
    ...
}
if (A == 5) {
    B = 0
    entity():applyForce(...)
}
with else/elseif-branch
if (...) {
    ...
} else {
    ...
}

if (Hello) {
    Goodbye = 0
} else {
    Goodbye = 1
}

Although for something so small it might as well be on one line
because if this is always done then expressions can be harder to read and intimidating.
Note that the above example is better written as:

Goodbye = !Hello
Nested if statements
if (...) {
    if (...) {...}
    if (...) {...}
}

if (A) {
    if (B) {
        C=1
    } else {
        C=0
    }

    if (D) {
        E=1
    } else {
        E=0
    }
}

As with the previous example you could just do something simpler
if (A) {
    C=B!=0
    E=D!=0
}

Обнаружено использование расширения AdBlock.


Викия — это свободный ресурс, который существует и развивается за счёт рекламы. Для блокирующих рекламу пользователей мы предоставляем модифицированную версию сайта.

Викия не будет доступна для последующих модификаций. Если вы желаете продолжать работать со страницей, то, пожалуйста, отключите расширение для блокировки рекламы.

Также на Фэндоме

Случайная вики