最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

javascript - Why my custom extension for turbowarp doesnt work? - Stack Overflow

matteradmin3PV0评论

why my custom extension for turbowarp doesnt work? so im trying to make a numeral encoder/decoder for turbowarp and im having problem that my extension not loading successfully into turbo warp when importing it. this is also question on how to make turbowarp extension since i just started creating turbowarp extesions.

const numeralEncoder = {
  id: 'numeralEncoder',
  name: 'Numeral Encoder/Decoder',
  blocks: [
    {
      opcode: 'encodeToNumbers',
      blockType: 'reporter',
      text: 'encode [text] to numbers',
      arguments: {
        text: {
          type: 'string',
          defaultValue: 'Hello'
        }
      },
      func: function(args) {
        return this.encodeToNumbers(args.text);
      }
    },
    {
      opcode: 'decodeFromNumbers',
      blockType: 'reporter',
      text: 'decode [numbers] to text',
      arguments: {
        numbers: {
          type: 'string',
          defaultValue: '72,101,108,108,111'
        }
      },
      func: function(args) {
        return this.decodeFromNumbers(args.numbers);
      }
    }
  ],

  encodeToNumbers: function(text) {
    const asciiValues = [];
    for (let i = 0; i < text.length; i++) {
      asciiValues.push(text.charCodeAt(i));
    }
    return asciiValues.join(',');
  },

  decodeFromNumbers: function(numbers) {
    const asciiValues = numbers.split(',').map(Number);
    let decodedString = '';
    for (let i = 0; i < asciiValues.length; i++) {
      decodedString += String.fromCharCode(asciiValues[i]);
    }
    return decodedString;
  }
};

Extension.register(numeralEncoder);
Post a comment

comment list (0)

  1. No comments so far