Skip to content

Commit

Permalink
Fixing interval variable handling
Browse files Browse the repository at this point in the history
  • Loading branch information
rossant committed Mar 12, 2024
1 parent 2e62b09 commit 1393a37
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
5 changes: 4 additions & 1 deletion scripts/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ ${locale.maroon} = (128, 50, 50);
${locale.purple} = (150, 100, 220);
# Global variables.
${locale.interval} = ${DEFAULT_INTERVAL}
# ${locale.interval} = ${DEFAULT_INTERVAL}
# Grid functions.
def ${locale.size}(n, m):
Expand All @@ -43,19 +43,22 @@ def ${locale.size}(n, m):
def ${locale.font}(size):
grid.font(f"{size}pt")
def ${locale.color}(i, j, col):
if callable(col): col = col()
grid.bgcolor(i, j, *col)
def ${locale.text}(i, j, text):
grid.text(i, j, text)
def ${locale.fill}(col):
grid.fill(*col)
def ${locale.clear}():
grid.clear()
def ${locale.line}(i, col):
grid.line(i, *col)
Expand Down
2 changes: 1 addition & 1 deletion scripts/locale.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export function addLocale(locale) {
let result = '';
for (const key in locale) {
if (Object.hasOwnProperty.call(locale, key)) {
result += `${locale[key]} = ${key}\n`;
result += `${locale[key]} = globals().get("${key}", None)\n`;
}
}
return result;
Expand Down
3 changes: 2 additions & 1 deletion scripts/runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ class Runner {

// Parse the interval: use the localized variable name.
// NOTE: use the code metadata instead.
let interval = this.get('interval', LANG);
let interval = this.get('interval', LANG) || this.get('interval');
if (interval)
this.interval = interval;

Expand Down Expand Up @@ -143,6 +143,7 @@ class Runner {
let locale = getLocale(lang);
varName = locale[varName];
}
if (!varName) return null;
return this.globals ? this.globals.toJs().get(varName) : null;
}

Expand Down

0 comments on commit 1393a37

Please sign in to comment.