Home › Forums › Programming › Custom puzzle – Multiline field issue
- This topic has 5 replies, 2 voices, and was last updated 3 years, 11 months ago by GLiFTeK.
-
AuthorPosts
-
2020-11-28 at 10:42 pm #36052GLiFTeKCustomer
Hi
I am testing the whole accessing input fields code area of making custom puzzles.I’ve added a multiline text field.
I have added a var for it using block.getFieldValue(name)
Have a console log for it as well.Yet console reads the inputted text value I type into the field is not defined.
Ie: Uncaught ReferenceError: blablabla is not defined.Any idea what might be the issue?
Visit the GLIFTEK Verge3D Plugins Store!
GLIFTEK.com for Plugin Documentation & LIVE DEMOS!
LIKE The GLIFTEK Facebook Page for updates!
Join the Verge 3D Discord Server!
plz share Discord link & on your signature!2020-11-30 at 7:31 am #36077Yuri KovelenovStaff2020-11-30 at 10:38 pm #36108GLiFTeKCustomercan you share your plugin?
Hi Yuri,
Here’s a puzzle that demonstrates the problem plus the other problem i was having with the multiline text field being not defined. (this time it’s just a simple text field.
the goal to test this puzzle would be just to plug it into a “set variable” puzzle, then have a console log print that variable.
The varable’s printed value should be the value of the text field.( i know i can do this with a simple text puzzle. i’m just trying to understand the processes of moving the text field value through the output sucessfully.
here’s the init.plug code:
<category name="My Puzzles" colour="teal"> <label text="My Puzzles"></label> <block type="Text Field With Output"></block> </category>
and the
‘Text Field With Output.block’ code:<script> function template(block) { // some basic styling block.appendDummyInput().appendField('Text Field With Output'); block.setColour('teal'); // set this block's type to 'String' block.setOutput(true, 'String'); // add text field with default string value block.appendDummyInput() .appendField(new Blockly.FieldTextInput('text'), 'MY_TEXT'); } function code(block) { var myText = block.getFieldValue('MY_TEXT'); var fun = Blockly.JavaScript.provideFunction_('myFunction', [
function ${Blockly.JavaScript.FUNCTION_NAME_PLACEHOLDER_}(text) {
console.log(‘my text: ‘, text);
return text;
}]); return
${fun}(
${myText}
);
`;
}</script>`
Thanks
Ps… The ticks in the code made the markup break up here. Any way around that?
Visit the GLIFTEK Verge3D Plugins Store!
GLIFTEK.com for Plugin Documentation & LIVE DEMOS!
LIKE The GLIFTEK Facebook Page for updates!
Join the Verge 3D Discord Server!
plz share Discord link & on your signature!2020-12-01 at 12:32 am #36111GLiFTeKCustomerAlso,
Just to review, when plugged into a set variable puzzle, my output puzzle causes the error: “expecting tuple from value block”And the text field says “myText is undefined”
Visit the GLIFTEK Verge3D Plugins Store!
GLIFTEK.com for Plugin Documentation & LIVE DEMOS!
LIKE The GLIFTEK Facebook Page for updates!
Join the Verge 3D Discord Server!
plz share Discord link & on your signature!2020-12-06 at 11:25 am #36231GLiFTeKCustomerAny idea why the output plug puzzle style gives the ‘expecting tuple’ error?
Visit the GLIFTEK Verge3D Plugins Store!
GLIFTEK.com for Plugin Documentation & LIVE DEMOS!
LIKE The GLIFTEK Facebook Page for updates!
Join the Verge 3D Discord Server!
plz share Discord link & on your signature!2020-12-07 at 1:05 pm #36242GLiFTeKCustomerSOLUTION for this problem here…
link to solution for setOutput ‘expected tuple’ console error
(notice i added a jpeg of the code because the .block file format uses tilda key ‘ticks’ which interferes with the way we present code on the forum, as seen in my above post.
I hope there can be a solution to this. i’ve already tried the BBCode [code] method, but this didn’t work.
possibly we can use double or triple ticks??)
Visit the GLIFTEK Verge3D Plugins Store!
GLIFTEK.com for Plugin Documentation & LIVE DEMOS!
LIKE The GLIFTEK Facebook Page for updates!
Join the Verge 3D Discord Server!
plz share Discord link & on your signature! -
AuthorPosts
- You must be logged in to reply to this topic.