Skip to main content

Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines

For nesting, check out concatenation - if you do num##ind,

foreach (num, list) {
    foreach (num2, list2) {
        // ...
    }
}

would get their own vars.

For getting the next value, that’s how it goes (and also you should account for zero-sized arrays)

(1 edit)

true true. I managed to make a better version. The huge block of code at the end of the for still annoys me tho.

#mfunc foreach(element, list) as "keyword" \
var list##_len = array_length(list); \ 
if (list##_len <= 0) {} \ 
else for (var element##_i = 0, element = list[0]; element##_i < list##_len; { element##_i++; if (element##_i < list##_len) element = list[element##_i] })