3 months ago

all this code

[article]

FOR JUST COLOR DETECTION AND KEY DECTION IN PENGUIN MOD GFEUWGFUAIS

and it doesnt work

[i used chat gpt and corrected it multiple times]


// color-and-keys-extension.js

(function (Scratch) {

'use strict';

class ColorAndKeyExtension {

getInfo() {

return {

id: 'colorAndKeyExtension_v2',

name: 'Color & Key Detector (v2)',

blocks: [

{

opcode: 'getColorUnderSprite',

blockType: Scratch.BlockType.REPORTER,

text: 'color under sprite'

},

{

opcode: 'getColorUnderSpriteAt',

blockType: Scratch.BlockType.REPORTER,

text: 'color under sprite at x: [X] y: [Y]',

arguments: {

X: { type: Scratch.ArgumentType.NUMBER, defaultValue: 0 },

Y: { type: Scratch.ArgumentType.NUMBER, defaultValue: 0 }

}

},

{

opcode: 'isKeyPressed',

blockType: Scratch.BlockType.BOOLEAN,

text: 'key [KEY] pressed?',

arguments: {

KEY: { type: Scratch.ArgumentType.STRING, defaultValue: 'space' }

}

},

{

opcode: 'keysPressedList',

blockType: Scratch.BlockType.REPORTER,

text: 'keys currently pressed'

}

]

};

}

_rgbToHex(r, g, b) {

const toHex = v => ('0' + Math.max(0, Math.min(255, Math.round(v))).toString(16)).slice(-2);

return '#' + toHex(r) + toHex(g) + toHex(b);

}

_getColorAtTarget(target, offsetX = 0, offsetY = 0) {

const vm = Scratch.vm;

const renderer = vm && vm.renderer;

const runtime = vm && vm.runtime;

if (!renderer || !runtime || !target) return '#000000';

const stageW = runtime.constructor.STAGE_WIDTH || 480;

const stageH = runtime.constructor.STAGE_HEIGHT || 360;

const xScratch = (target.x || 0) + Number(offsetX || 0);

const yScratch = (target.y || 0) + Number(offsetY || 0);

// Scratch→pick coords: (0,0) is center

const pickX = Math.round(xScratch + stageW / 2);

const pickY = Math.round(-yScratch + stageH / 2);

let pickResult;

try {

pickResult = renderer.pick(pickX, pickY, null, null);

} catch (e) {

return '#000000';

}

if (!pickResult) return '#000000';

let r, g, b;

if (Array.isArray(pickResult)) {

[ , r, g, b ] = pickResult;

} else if (typeof pickResult === 'object') {

({ r, g, b } = pickResult);

}

if (typeof r !== 'number') return '#000000';

return this._rgbToHex(r, g, b);

}

getColorUnderSprite(args, util) {

return this._getColorAtTarget(util.target, 0, 0);

}

getColorUnderSpriteAt(args, util) {

return this._getColorAtTarget(util.target, Number(args.X), Number(args.Y));

}

isKeyPressed(args) {

const key = String(args.KEY || '').toLowerCase();

const kbd = Scratch.vm.runtime.ioDevices.keyboard;

return kbd && kbd.getKeyIsDown(key);

}

keysPressedList() {

const kbd = Scratch.vm.runtime.ioDevices.keyboard;

if (!kbd || !kbd.getKeyIsDown) return '';

const keys = [];

for (le



0 comments

Loading...

Next up

server: say=get

get any item or thing u type in chat

meanwhile me;

icebiome yay

i make ppl say buy a life

why wont it work

then i finnaly get something thats a gamble thing

does it just make me more broke

this command is funny wanna kwno what it does?

image2 XD

U CALLING ME LAZY?????!?!?!??!?!???

i cant

sorry XD

actually thats a good thing that i cant

thx the 50%-

that voted im already that good and i will get there

altho i do think the last one is realistic since makign something like that on beepbox is hard

im collecting multiple smp's world code