diff --git a/editor.html b/editor.html
index ee0a527..50c5c51 100644
--- a/editor.html
+++ b/editor.html
@@ -267,7 +267,7 @@
function builtinRead(x) {
if (x === 'screen' || x === './screen.js') {
- const url = new URL('screen.js', window.location.href).href;
+ const url = new URL('screen.js?t=' + Date.now(), window.location.href).href;
const xhr = new XMLHttpRequest();
xhr.open("GET", url, false);
xhr.send();
diff --git a/screen.js b/screen.js
index 66a157d..94cb01a 100644
--- a/screen.js
+++ b/screen.js
@@ -128,9 +128,12 @@ var $builtinmodule = function (name) {
return Sk.builtin.none.none$;
});
+ var current_dt = 0;
+
function makeSafePyCallbackNoArgs(pyFunc) {
if (!pyFunc || pyFunc === Sk.builtin.none.none$) return null;
- return function () {
+ return function (dt) {
+ if (typeof dt === 'number') current_dt = dt;
try { return Sk.misceval.callsimArray(pyFunc, []); }
catch (e) {
if (window.outf) window.outf(`[Error] ${e}\n`);
@@ -142,7 +145,10 @@ var $builtinmodule = function (name) {
function makePyCallbackNoArgs(pyFunc) {
if (!pyFunc || pyFunc === Sk.builtin.none.none$) return null;
- return function () { return Sk.misceval.callsimArray(pyFunc, []); };
+ return function (dt) {
+ if (typeof dt === 'number') current_dt = dt;
+ return Sk.misceval.callsimArray(pyFunc, []);
+ };
}
function makePyCallbackTapArgs(pyFunc) {
@@ -162,10 +168,16 @@ var $builtinmodule = function (name) {
};
}
+ console.log("LiteCanvas Screen Module Loaded (v1.2)");
Object.defineProperty(mod, 'T', { get: function () { return toPy(lc_instance ? lc_instance.T : (window.T || 0)); } });
Object.defineProperty(mod, 'W', { get: function () { return toPy(lc_instance ? lc_instance.W : (window.W || 0)); } });
Object.defineProperty(mod, 'H', { get: function () { return toPy(lc_instance ? lc_instance.H : (window.H || 0)); } });
- Object.defineProperty(mod, 'DT', { get: function () { return toPy(lc_instance ? lc_instance.dt : (window.dt || 0)); } });
+ Object.defineProperty(mod, 'DT', {
+ get: function () {
+ if (lc_instance && lc_instance.dt !== undefined) return toPy(lc_instance.dt);
+ return toPy(current_dt);
+ }
+ });
Object.defineProperty(mod, 'MX', {
get: function () {
let mx = lc_instance ? lc_instance.MX : (window.MX || -1);