We use cookies to ensure that we give you the best experience on our website. If you continue to use this site we will assume that you are happy with it.

Need help with reading ValueInput ‘TEXT’ feild.

Home Forums Programming Need help with reading ValueInput ‘TEXT’ feild.

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #54186
    kdv
    Participant

    I’m trying to make a plugin that will put a text into visual_logic.js as is.

        this.appendValueInput('TEXT')
            .setCheck('String')
            .appendField('exec Script');
        var text = Blockly.JavaScript.valueToCode(block, 'TEXT', Blockly.JavaScript.ORDER_NONE);
        return '${text}\n';

    this code returns the following

    ('console.log(\'Hello, Verge!\');' + '\n' +
    'console.log(\'Hello, Verge!\');' + '\n' +
    'console.log(\'Hello, Verge!\');')

    but I need to get this

    console.log('Hello, Verge!');
    console.log('Hello, Verge!');
    console.log('Hello, Verge!');

    Is there a way to read ValueInput field as it was written in the text puzzle without using text.replace?

    Puzzles and JS coding. Fast and expensive.

    If you don’t see the meaning in something it primarily means that you just don’t see it but not the absence of the meaning at all.

    #54205

    Hi, that’s the default behavior of the textMultiline puzzle. In order to output its content as it is you need to simply return the value of its TEXT field:

    
    const textBlock = block.getInputTargetBlock('TEXT');
    if (textBlock !== null && textBlock.type === "textMultiline") {
        return textBlock.getFieldValue('TEXT');
    }
    
    // default behavior for other input blocks
    var text = Blockly.JavaScript.valueToCode(block, 'TEXT', Blockly.JavaScript.ORDER_NONE);
    return '${text}\n';
    

    Co-founder and lead developer at Soft8Soft.

    #54206
    kdv
    Participant

    Thanks a lot!

    Puzzles and JS coding. Fast and expensive.

    If you don’t see the meaning in something it primarily means that you just don’t see it but not the absence of the meaning at all.

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.