CursedSliver

reediting

Sep 6th, 2024 (edited)
179
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var updooter = null;
  2. Game.registerMod('updooter', {
  3.     init: function() {
  4.         if (typeof CrumbsEngineLoaded === 'undefined' || !CrumbsEngineLoaded) { Game.LoadMod('https://raw.githack.com/CursedSliver/Crumbs-engine/main/Crumbs.js'); }
  5.         const checkPrerequisites = function(self) {
  6.             if (typeof CrumbsEngineLoaded !== 'undefined' && CrumbsEngineLoaded) { self.header(); clearInterval(interval); }
  7.         }
  8.         const interval = setInterval(checkPrerequisites, 10, this);
  9.         updooter = this;
  10.     },
  11.     header: function() {
  12.         Game.Notify('Updoot mod loaded!', '', [26, 7]);
  13.         const bigCookieFragmentBehavior = new Crumbs.behaviorInstance(function() {
  14.                 for (let i in this.children) {
  15.                     if (this.children[i].ownComponent.hovered) { this.hovered = true; return; }
  16.                 }
  17.                 this.hovered = false;
  18.             });
  19.         let stuff = {
  20.             imgs: 'https://rawcdn.githack.com/CursedSliver/asdoindwalk/031b0de87d0faec46b9c7d30f8f90721fd536057/perfectlyBrokenCookie.png',
  21.             width: 512,
  22.             height: 512,
  23.             order: -1,
  24.             id: 'frag',
  25.             sx: 0,
  26.             hovered: false,
  27.             behaviors: bigCookieFragmentBehavior
  28.         };
  29.         this.display = Crumbs.findObject('bigCookie').findChild('bigCookieDisplay');
  30.         this.display.noDraw = true;
  31.         this.display.hovered = true;
  32.        
  33.         this.bigCookieMain = Crumbs.findObject('bigCookie');
  34.         this.bigCookieMain.width = 256;
  35.         this.bigCookieMain.height = 256;
  36.         this.display.addBehavior(new Crumbs.behaviorInstance(function() {
  37.             for (let i in this.children) {
  38.                 if (this.children[i].id != 'frag' || !this.children[i].enabled) { continue; }
  39.                 if (this.children[i].hovered) { this.hovered = true; return; }
  40.             }
  41.             this.hovered = false;
  42.         }));
  43.         this.bigCookieMain.addComponent(new Crumbs.component.pointerInteractive({
  44.             onRelease: function() { if (updooter.display.hovered) { Game.ClickCookie(); } },
  45.             boundingType: 'oval'
  46.         }));
  47.         this.bigCookieMain.addBehavior(new Crumbs.behaviorInstance(function() {
  48.             if (!updooter.display.hovered) { Game.bigCookieState = 0; return; }
  49.            
  50.             if (this.getComponent('pointerInteractive').click) { Game.BigCookieState = 1; }
  51.             else if (this.getComponent('pointerInteractive').hovered) { Game.BigCookieState = 2; }
  52.             else { Game.BigCookieState = 0; }
  53.         }));
  54.         let fragmentHitBoxMap = {
  55.             0: [{x: 0, y: 0, r: 0, w: 512, h: 512 }],
  56.             1: [],
  57.             2: [],
  58.             3: [],
  59.             4: [],
  60.             5: [],
  61.             6: [],
  62.             7: [],
  63.             8: []
  64.         }
  65.         for (let i = 0; i < 9; i++) {
  66.             stuff.sx = i * 512;
  67.             stuff.order = -1 + i * 0.001;
  68.             const child = this.display.spawnChild(stuff);
  69.             for (let ii in fragmentHitBoxMap[i]) {
  70.                 const childChild = child.spawnChild({
  71.                     x: fragmentHitBoxMap[i][ii].x,
  72.                     y: fragmentHitBoxMap[i][ii].y,
  73.                     rotation: fragmentHitBoxMap[i][ii].r,
  74.                     width: fragmentHitBoxMap[i][ii].w,
  75.                     height: fragmentHitBoxMap[i][ii].h,
  76.                     components: new Crumbs.component.pointerInteractive({ boundingType: fragmentHitBoxMap[i][ii].type??'rect', alwaysInteractable: true, onClick: function() { console.log('true'); } }),
  77.                     behaviors: function() { if (this.getComponent('pointerInteractive').hovered) { console.log('yes!!!'); } }
  78.                 });
  79.                 childChild.ownComponent = childChild.getComponent('pointerInteractive');
  80.             }
  81.         }
  82.        
  83.         l('bigCookie').remove();
  84.         var bigCookie = document.createElement('button');
  85.         bigCookie.id = 'bigCookie';
  86.         l('cookieAnchor').appendChild(bigCookie);
  87.     },
  88.     bigCookieMain: null,
  89.     display: null,
  90.     save: function() {
  91.    
  92.     },
  93.     load: function() {
  94.    
  95.     }
  96. });
Advertisement
Add Comment
Please, Sign In to add comment