Skip to content
Closed
39 changes: 9 additions & 30 deletions src/lib/extensions.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,19 +140,6 @@ export default [
documentation: "PenguinAI",
unstableReason: "AI models can generate unintended or inappropriate output.\nSome AI models may also become temporarily inaccessible.\n\nUse at your own risk.",
},
/*
{
name: "Block AI",
description: "An AI powered chat bot to help you code in your projects.",
code: "TheShovel/blockAI.js",
banner: "TheShovel/thumbnail-blockAI.png",
creator: "TheShovel",
creatorAlias: "TheShovel",
isGitHub: true,
unstable: true,
unstableReason: "The AI model can generate inaccurate output and broken syntax!",
},
*/
{
name: "PenguinHook",
description: "Send Webhook requests, that can be Discord or any type of webhook.",
Expand Down Expand Up @@ -272,15 +259,6 @@ export default [
banner: "NamelessCat/corsproxy.png",
creator: "NamelessCat",
},
// { // temporary due to licensing issues
// name: "Extension Exposer",
// description: "Access the raw functions from other extensions.",
// code: "TheShovel/extexp.js",
// banner: "TheShovel/placeholder-extexp.png",
// creator: "TheShovel",
// isGitHub: true,
// note: "Some contributions by yuri-kiss :P",
// },
{
name: "Project Page",
description: "Modify and affect the studio project page from the code. How annoying can an extension possibly be?",
Expand All @@ -297,14 +275,6 @@ export default [
creator: "LilyMakesThings",
isGitHub: false,
},
// { // temporary due to licensing issues
// name: "More Fields",
// description: "Custom Field Types",
// code: "Ashime/MoreFields.js",
// banner: "0znzw/MoreFields.png",
// creator: "yuri-kiss",
// isGitHub: true,
// },
{
name: "Beepbox Player",
description: "Play, edit, and read songs from any BeepBox mod directly from the URL or JSON!",
Expand Down Expand Up @@ -472,6 +442,15 @@ export default [
creatorAlias: "gaimerI17",
note: "Extension thumbnail made by Dillon."
},
{
name: "Pointer Lock Pro",
description: "Locks and hides your pointer while recording your mouse movement—best to use in 3D games and custom camera systems.",
code: "supercodes_/pointerlockpro.js",
banner: "supercodes_/pointerlockpro.png",
creator: "supercodes_",
isGitHub: false,
isSandboxed: false,
},
/* these extensions are completely dead as of now
{
name: "Online Captcha",
Expand Down
75 changes: 75 additions & 0 deletions static/extensions/supercodes_/pointerlockpro.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
(function(Scratch) {
'use strict';

let moveX = 0;
let moveY = 0;

class PointerLockPro {
getInfo() {
return {
id: 'supercodesPointerLockPro',
name: 'Pointer Lock Pro',
blocks: [
{
opcode: 'lockPointer',
blockType: Scratch.BlockType.COMMAND,
text: 'lock pointer'
},
{
opcode: 'exitPointerLock',
blockType: Scratch.BlockType.COMMAND,
text: 'escape pointer lock'
},
{
opcode: 'isPointerLocked',
blockType: Scratch.BlockType.REPORTER,
text: 'pointer locked?'
},
{
opcode: 'getMovementX',
blockType: Scratch.BlockType.REPORTER,
text: 'mouse movement x'
},
{
opcode: 'getMovementY',
blockType: Scratch.BlockType.REPORTER,
text: 'mouse movement y'
}
]
};
}

lockPointer() {
const canvas = document.querySelector('canvas');
if (canvas) canvas.requestPointerLock();
}

exitPointerLock() {
if (document.exitPointerLock) document.exitPointerLock();
}

isPointerLocked() {
return String(!!document.pointerLockElement);
}

getMovementX() { return moveX; }
getMovementY() { return moveY; }
}

document.addEventListener('mousemove', (e) => {
if (document.pointerLockElement) {
moveX = e.movementX;
moveY = -e.movementY;
} else {
moveX = 0;
moveY = 0;
}
});

const ext = new PointerLockPro();
Scratch.extensions.register(ext);

Scratch.vm.runtime.on('PROJECT_STOP_ALL', () => {
if (document.exitPointerLock) document.exitPointerLock();
});
})(Scratch);
Binary file added static/images/pointerlockpro.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.