|
4 | 4 | // By: SharkPool |
5 | 5 | // License: MIT |
6 | 6 |
|
7 | | -// Version 2.0.0 |
| 7 | +// Version 2.0.01 |
8 | 8 |
|
9 | 9 | (function (Scratch) { |
10 | 10 | "use strict"; |
|
612 | 612 | return `#${rgb.r.toString(16).padStart(2, "0")}${rgb.g.toString(16).padStart(2, "0")}${rgb.b.toString(16).padStart(2, "0")}`; |
613 | 613 | } |
614 | 614 |
|
615 | | - getTarget(name, util, checkMouse, checkMyself, returnName) { |
| 615 | + getTarget(name, util, checkMouse, checkMyself) { |
616 | 616 | if (checkMouse && name === "_mouse_") return "_mouse_"; |
617 | | - if (checkMyself && name === "_myself_") return returnName ? util.target.getName() : util.target; |
618 | | - |
619 | | - const target = runtime.getSpriteTargetByName(name); |
620 | | - if (returnName) return target ? target.getName() : name; |
621 | | - else return target; |
| 617 | + if (checkMyself && name === "_myself_") return util.target; |
| 618 | + return runtime.getSpriteTargetByName(name); |
622 | 619 | } |
623 | 620 |
|
624 | 621 | updateAskMonitor() { |
|
761 | 758 | } |
762 | 759 |
|
763 | 760 | spritePointing(args, util) { |
764 | | - const target = this.getTarget(args.SPRITE1, util, false, true, false); |
| 761 | + const target = this.getTarget(args.SPRITE1, util, false, true); |
765 | 762 | if (!target) return false; |
766 | 763 | const oldDir = target.direction; |
767 | 764 | runtime.ext_scratch3_motion.pointTowards({ TOWARDS: args.SPRITE2 }, { ...util, target, ioQuery: util.ioQuery }); |
|
771 | 768 | } |
772 | 769 |
|
773 | 770 | spriteTouchingSprite(args, util) { |
774 | | - const target = this.getTarget(args.SPRITE2, util, false, true, false); |
| 771 | + const target = this.getTarget(args.SPRITE2, util, false, true); |
775 | 772 | if (!target) return false; |
776 | 773 | return target.sprite.clones.some((t) => t.isTouchingObject(args.SPRITE1)); |
777 | 774 | } |
778 | 775 |
|
779 | 776 | spriteTouchingSpriteType(args, util) { |
780 | | - const target1 = this.getTarget(args.SPRITE1, util, true, true, false); |
| 777 | + const target1 = this.getTarget(args.SPRITE1, util, true, true); |
781 | 778 | const target2 = runtime.getSpriteTargetByName(args.SPRITE2); |
782 | 779 | if (!target1 || !target2) return false; |
783 | 780 | if (args.TYPE === "parent") { |
|
795 | 792 | } |
796 | 793 |
|
797 | 794 | spriteTouchingClone(args, util) { |
798 | | - const target1 = this.getTarget(args.SPRITE1, util, true, true, false); |
| 795 | + const target1 = this.getTarget(args.SPRITE1, util, true, true); |
799 | 796 | const target2 = runtime.getSpriteTargetByName(args.SPRITE2); |
800 | 797 | if (!target1 || !target2) return false; |
801 | 798 |
|
|
815 | 812 |
|
816 | 813 | spritesTouching(args, util) { |
817 | 814 | const list = []; |
818 | | - const thisSprite = this.getTarget(args.SPRITE, util, true, true, true); |
| 815 | + const thisSprite = this.getTarget(args.SPRITE, util, true, true); |
| 816 | + if (!thisSprite) return "[]"; |
819 | 817 | const targets = runtime.targets; |
820 | | - for (let i = 1; i < targets.length; i++) { |
821 | | - const target = targets[i]; |
822 | | - const name = `${target.getName()}${target.isOriginal ? "" : " (Clone)"}`; |
823 | | - if (target.isTouchingObject(thisSprite) && name !== thisSprite) list.push(name); |
| 818 | + if (thisSprite === "_mouse_") { |
| 819 | + for (let i = 1; i < targets.length; i++) { |
| 820 | + const target = targets[i]; |
| 821 | + const name = `${target.getName()}${target.isOriginal ? "" : " (Clone)"}`; |
| 822 | + if (target.isTouchingObject(thisSprite)) list.push(name); |
| 823 | + } |
| 824 | + } else { |
| 825 | + for (let i = 1; i < targets.length; i++) { |
| 826 | + const target = targets[i]; |
| 827 | + if (target.id === thisSprite.id) continue; |
| 828 | + |
| 829 | + const name = `${target.getName()}${target.isOriginal ? "" : " (Clone)"}`; |
| 830 | + if (render.isTouchingDrawables(thisSprite.drawableID, [target.drawableID])) list.push(name); |
| 831 | + } |
824 | 832 | } |
825 | 833 | return JSON.stringify(list); |
826 | 834 | } |
|
849 | 857 | objTouchingColor(args, util) { |
850 | 858 | if (args.SPRITE === "_mouse_") return this.colorAtPos(util.ioQuery("mouse", "getScratchX"), util.ioQuery("mouse", "getScratchY")); |
851 | 859 | else { |
852 | | - const target = this.getTarget(args.SPRITE, util, false, true, false); |
| 860 | + const target = this.getTarget(args.SPRITE, util, false, true); |
853 | 861 | if (!target) return ""; |
854 | 862 | const wasVisible = target.visible; |
855 | 863 | target.setVisible(false); |
|
860 | 868 | } |
861 | 869 |
|
862 | 870 | spriteDragMode(args, util) { |
863 | | - const target = this.getTarget(args.SPRITE, util, false, true, false); |
| 871 | + const target = this.getTarget(args.SPRITE, util, false, true); |
864 | 872 | if (target) target.setDraggable(args.DRAG === "draggable"); |
865 | 873 | } |
866 | 874 | spriteDraggable(args, util) { |
867 | | - const target = this.getTarget(args.SPRITE, util, false, true, false); |
| 875 | + const target = this.getTarget(args.SPRITE, util, false, true); |
868 | 876 | if (target) return target[args.DRAG === "draggable" ? "draggable" : "dragging"]; |
869 | 877 | return false; |
870 | 878 | } |
|
0 commit comments