Skip to content

Pull down "use-cast" (not main PR) #2001

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

Draft
wants to merge 11 commits into
base: use-cast
Choose a base branch
from
1 change: 1 addition & 0 deletions extensions/-SIPC-/recording.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@
recordedChunks = [];
}
stopRecordingAndDownload({ name }) {
name = Scratch.Cast.toString(name);
if (!mediaRecorder) {
console.error("Recording not started");
return;
Expand Down
10 changes: 10 additions & 0 deletions extensions/0832/rxFS.js
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,8 @@
}

sync({ STR, STR2 }) {
STR = Scratch.Cast.toString(STR);
STR2 = Scratch.Cast.toString(STR2);
str = btoa(unescape(encodeURIComponent(STR)));
str2 = btoa(unescape(encodeURIComponent(STR2)));
if (rxFSsy.indexOf(str) + 1 == 0) {
Expand All @@ -178,6 +180,7 @@
}

start({ STR }) {
STR = Scratch.Cast.toString(STR);
str = btoa(unescape(encodeURIComponent(STR)));
if (
!(str.charAt(str.length - 1) == "/") &&
Expand All @@ -189,6 +192,7 @@
}

open({ STR }) {
STR = Scratch.Cast.toString(STR);
return decodeURIComponent(
escape(
atob(
Expand All @@ -201,6 +205,7 @@
}

del({ STR }) {
STR = Scratch.Cast.toString(STR);
str = btoa(unescape(encodeURIComponent(STR)));
const index = rxFSsy.indexOf(str);
if (index !== -1) {
Expand All @@ -210,11 +215,14 @@
}

file({ STR, STR2 }) {
STR = Scratch.Cast.toString(STR);
STR2 = Scratch.Cast.toString(STR2);
rxFSfi[rxFSsy.indexOf(btoa(unescape(encodeURIComponent(STR)))) + 1 - 1] =
btoa(unescape(encodeURIComponent(STR2)));
}

search({ STR }) {
STR = Scratch.Cast.toString(STR);
Search = "";
i = 0;
str = btoa(unescape(encodeURIComponent(STR)));
Expand All @@ -239,6 +247,7 @@
}

webin({ STR }) {
STR = Scratch.Cast.toString(STR);
return Scratch.fetch(STR)
.then((response) => {
return response.text();
Expand All @@ -250,6 +259,7 @@
}

in({ STR }) {
STR = Scratch.Cast.toString(STR);
rxFSfi = STR.slice(0, STR.indexOf("|")).split(",");
rxFSsy = STR.slice(STR.indexOf("|") + 1, STR.length).split(",");
}
Expand Down
12 changes: 12 additions & 0 deletions extensions/0832/rxFS2.js
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,8 @@
}

sync({ STR, STR2 }) {
STR = Scratch.Cast.toString(STR);
STR2 = Scratch.Cast.toString(STR2);
str = encodeURIComponent(STR);
str2 = encodeURIComponent(STR2);
if (rxFSsy.indexOf(str) + 1 == 0) {
Expand All @@ -209,6 +211,7 @@
}

start({ STR }) {
STR = Scratch.Cast.toString(STR);
str = encodeURIComponent(STR);
if (
!(str.charAt(str.length - 1) == "/") &&
Expand All @@ -220,12 +223,15 @@
}

open({ STR }) {
STR = Scratch.Cast.toString(STR);
return decodeURIComponent(
rxFSfi[rxFSsy.indexOf(encodeURIComponent(STR)) + 1 - 1]
);
}

del({ STR }) {
STR = Scratch.Cast.toString(STR);
STR2 = Scratch.Cast.toString(STR2);

Check failure on line 234 in extensions/0832/rxFS2.js

View workflow job for this annotation

GitHub Actions / lint

'STR2' is not defined

Check failure on line 234 in extensions/0832/rxFS2.js

View workflow job for this annotation

GitHub Actions / lint

'STR2' is not defined
str = encodeURIComponent(STR);
const index = rxFSsy.indexOf(str);
if (index !== -1) {
Expand All @@ -235,11 +241,14 @@
}

folder({ STR, STR2 }) {
STR = Scratch.Cast.toString(STR);
STR2 = Scratch.Cast.toString(STR2);
rxFSfi[rxFSsy.indexOf(encodeURIComponent(STR)) + 1 - 1] =
encodeURIComponent(STR2);
}

search({ STR }) {
STR = Scratch.Cast.toString(STR);
Search = "";
i = 0;
str = encodeURIComponent(STR);
Expand All @@ -252,6 +261,7 @@
}

list({ STR }) {
STR = Scratch.Cast.toString(STR);
Search = "";
i = 0;
str = encodeURIComponent(STR);
Expand All @@ -264,6 +274,7 @@
}

webin({ STR }) {
STR = Scratch.Cast.toString(STR);
return Scratch.fetch(STR)
.then((response) => {
return response.text();
Expand All @@ -275,6 +286,7 @@
}

in({ STR }) {
STR = Scratch.Cast.toString(STR);
rxFSfi = STR.slice(0, STR.indexOf("|")).split(",");
rxFSsy = STR.slice(STR.indexOf("|") + 1, STR.length).split(",");
}
Expand Down
4 changes: 2 additions & 2 deletions extensions/CST1229/images.js
Original file line number Diff line number Diff line change
Expand Up @@ -273,8 +273,8 @@
img.updateVisible(false);
img.skin = this.render._allSkins[IMG];

img.updatePosition([Number(X) || 0, Number(Y) || 0]);
img.updateScale([Number(XSCALE) || 0, Number(YSCALE) || 0]);
img.updatePosition([Scratch.Cast.toNumber(X) || 0, Scratch.Cast.toNumber(Y) || 0]);
img.updateScale([Scratch.Cast.toNumber(XSCALE) || 0, Scratch.Cast.toNumber(YSCALE) || 0]);
this.render.penStamp(this.render._penSkinId, drawableID);
} catch (e) {
console.error("Error drawing image:", e);
Expand Down
4 changes: 2 additions & 2 deletions extensions/CST1229/zip.js
Original file line number Diff line number Diff line change
Expand Up @@ -625,8 +625,8 @@
/// Utilities

normalize(origin, path) {
path = path.toString().replaceAll(/\\/g, "/");
origin = origin.toString().replaceAll(/\\/g, "/");
path = Scratch.Cast.toString(path).replaceAll(/\\/g, "/");
origin = Scratch.Cast.toString(origin).replaceAll(/\\/g, "/");

if (path.startsWith("/")) origin = "";
else if (!origin.endsWith("/")) origin += "/";
Expand Down
18 changes: 16 additions & 2 deletions extensions/CubesterYT/WindowControls.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// Original: BlueDome77
// License: MIT

// Version V.1.0.0
// Version V.1.0.1

(function (Scratch) {
"use strict";
Expand Down Expand Up @@ -370,10 +370,13 @@
}

moveTo(args) {
args.X = Scratch.Cast.toNumber(args.X);
args.Y = Scratch.Cast.toNumber(args.Y);
window.moveTo(args.X, args.Y);
Scratch.vm.runtime.requestRedraw();
}
moveToPresets(args) {
args.PRESETS = Scratch.Cast.toString(args.PRESETS);
if (args.PRESETS == "center") {
const left = (screen.width - window.outerWidth) / 2;
const top = (screen.height - window.outerHeight) / 2;
Expand Down Expand Up @@ -412,19 +415,23 @@
Scratch.vm.runtime.requestRedraw();
}
changeX(args) {
args.X = Scratch.Cast.toNumber(args.X);
window.moveBy(args.X, 0);
Scratch.vm.runtime.requestRedraw();
}
setX(args) {
args.X = Scratch.Cast.toNumber(args.X);
const currentY = window.screenY;
window.moveTo(args.X, currentY);
Scratch.vm.runtime.requestRedraw();
}
changeY(args) {
args.X = Scratch.Cast.toNumber(args.Y);
window.moveBy(0, args.Y);
Scratch.vm.runtime.requestRedraw();
}
setY(args) {
args.Y = Scratch.Cast.toNumber(args.Y);
const currentX = window.screenX;
window.moveTo(currentX, args.Y);
Scratch.vm.runtime.requestRedraw();
Expand All @@ -436,10 +443,13 @@
return window.screenTop;
}
resizeTo(args) {
args.W = Scratch.Cast.toNumber(args.W);
args.H = Scratch.Cast.toNumber(args.H);
window.resizeTo(args.W, args.H);
Scratch.vm.runtime.requestRedraw();
}
resizeToPresets(args) {
args.PRESETS = Scratch.Cast.toString(args.PRESETS);
if (args.PRESETS == "480x360") {
window.resizeTo(
480 + (window.outerWidth - window.innerWidth),
Expand Down Expand Up @@ -484,19 +494,23 @@
Scratch.vm.runtime.requestRedraw();
}
changeW(args) {
args.W = Scratch.Cast.toNumber(args.W);
window.resizeBy(args.W, 0);
Scratch.vm.runtime.requestRedraw();
}
setW(args) {
args.W = Scratch.Cast.toNumber(args.W);
const currentH = window.outerHeight;
window.resizeTo(args.W, currentH);
Scratch.vm.runtime.requestRedraw();
}
changeH(args) {
args.H = Scratch.Cast.toNumber(args.H);
window.resizeBy(0, args.H);
Scratch.vm.runtime.requestRedraw();
}
setH(args) {
args.H = Scratch.Cast.toNumber(args.H);
const currentW = window.outerWidth;
window.resizeTo(currentW, args.H);
Scratch.vm.runtime.requestRedraw();
Expand Down Expand Up @@ -535,7 +549,7 @@
return document.hasFocus();
}
changeTitleTo(args) {
document.title = args.TITLE;
document.title = Scratch.Cast.toString(args.TITLE);
}
windowTitle() {
return document.title;
Expand Down
22 changes: 11 additions & 11 deletions extensions/DT/cameracontrols.js
Original file line number Diff line number Diff line change
Expand Up @@ -505,53 +505,53 @@
}

setBoth(args, util) {
cameraX = +args.x;
cameraY = +args.y;
cameraX = Scratch.Cast.toNumber(args.x) || 0;
cameraY = Scratch.Cast.toNumber(args.y) || 0;
updateCamera();
vm.runtime.requestRedraw();
}
changeZoom(args, util) {
cameraZoom += +args.val;
cameraZoom += Scratch.Cast.toNumber(args.val) || 0;
updateCamera();
vm.runtime.requestRedraw();
}
setZoom(args, util) {
cameraZoom = +args.val;
cameraZoom = Scratch.Cast.toNumber(args.val) || 0;
updateCamera();
vm.runtime.requestRedraw();
}
changeX(args, util) {
cameraX += +args.val;
cameraX += Scratch.Cast.toNumber(args.val) || 0;
updateCamera();
vm.runtime.requestRedraw();
}
setX(args, util) {
cameraX = +args.val;
cameraX = Scratch.Cast.toNumber(args.val) || 0;
updateCamera();
vm.runtime.requestRedraw();
}
changeY(args, util) {
cameraY += +args.val;
cameraY += Scratch.Cast.toNumber(args.val) || 0;
updateCamera();
vm.runtime.requestRedraw();
}
setY(args, util) {
cameraY = +args.val;
cameraY = Scratch.Cast.toNumber(args.val) || 0;
updateCamera();
vm.runtime.requestRedraw();
}
setDirection(args, util) {
cameraDirection = +args.val;
cameraDirection = Scratch.Cast.toNumber(args.val) || 0;
updateCamera();
vm.runtime.requestRedraw();
}
rotateCW(args, util) {
cameraDirection = cameraDirection + +args.val;
cameraDirection = cameraDirection + (Scratch.Cast.toNumber(args.val) || 0);
updateCamera();
vm.runtime.requestRedraw();
}
rotateCCW(args, util) {
cameraDirection = cameraDirection - +args.val;
cameraDirection = cameraDirection - (Scratch.Cast.toNumber(args.val) || 0);
updateCamera();
vm.runtime.requestRedraw();
}
Expand Down
1 change: 1 addition & 0 deletions extensions/JeremyGamer13/tween.js
Original file line number Diff line number Diff line change
Expand Up @@ -576,6 +576,7 @@
}

tweenProperty(args, util) {
args.PROPERTY = Cast.toString(args.PROPERTY);
let currentValue = 0;
if (args.PROPERTY === "x position") {
currentValue = util.target.x;
Expand Down
8 changes: 4 additions & 4 deletions extensions/Lily/LooksPlus.js
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@
}
const drawableID = target.drawableID;
const layerOrder = target.getLayerOrder();
const newLayer = args.LAYER - layerOrder;
const newLayer = Scratch.Cast.toNumber(args.LAYER) - layerOrder;
renderer.setDrawableOrder(drawableID, newLayer, "sprite", true);
}

Expand Down Expand Up @@ -466,7 +466,7 @@
return;
}

const contentType = args.TYPE;
const contentType = Scratch.Cast.toString(args.TYPE);
const content = args.CONTENT;
if (contentType === "SVG") {
try {
Expand Down Expand Up @@ -532,13 +532,13 @@
return "";
}

const costume = target.sprite.costumes[args.COSTUME - 1];
const costume = target.sprite.costumes[Scratch.Cast.toNumber(args.COSTUME) - 1];
if (!costume) {
console.error("Target costume does not exist");
return "";
}

const format = args.CONTENT;
const format = Scratch.Cast.toString(args.CONTENT);
if (format === "content") {
return costume.asset.decodeText();
} else {
Expand Down
Loading
Loading