-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix codigo de bloque repetir #305
Conversation
toolboxJSON: { | ||
"kind": "block", | ||
"type": "Repetir", | ||
"inputs": { | ||
"count": { | ||
"block": { | ||
"type": "math_number", | ||
"fields": { | ||
"NUM": 10 | ||
} | ||
} | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Esto es necesario para que en el toolbox, el bloque repetir aparezca con el bloque numérico adentro, lo que lo diferencia del repetir vacío
categoryId: 'primitives', | ||
toolboxJSON: { | ||
"kind": "block", | ||
"type": "SaltarHaciaAdelante", | ||
"inputs": { | ||
"longitud": { | ||
"block": { | ||
"type": "math_number", | ||
"fields": { | ||
"NUM": 100 | ||
} | ||
} | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Habían otros bloques, en específico los de Mañic de dibujo, que usaban bloques que deberían aparecer en el toolbox con un bloque numérico ya conectado, los agregué
var code = ''; | ||
|
||
const loopVar = generator.nameDB_.getDistinctName( | ||
'count', Blockly.Names.NameType.VARIABLE); | ||
var endVar = repeats; | ||
if (!repeats.match(/^\w+$/) && Blockly.utils.string.isNumber(repeats)) { | ||
if (!repeats.toString().match(/^\w+$/) && Blockly.utils.string.isNumber(repeats)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No deja hacer un match con un número
init: Blockly.Blocks['math_number'].init, | ||
categoryId: Blockly.Blocks['math_number'].categoryId, | ||
} | ||
|
||
javascriptGenerator.forBlock['Numero'] = function (block: Block) { | ||
return [`${block.getFieldValue('NUM')}`, Order.ATOMIC]; | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cree el bloque "Numero" más que nada para replicar el alias que tenía en versiones viejas y que sigan andando viejas soluciones.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bravo !!!
/** | ||
* Some blocks, like "Repetir" need to be attached to a math_number block on toolbox, that's why they have toolboxJSON property | ||
*/ | ||
const blockTypeToToolboxBlock = (block: BlockType): any => block.toolboxJSON ? block.toolboxJSON : { kind: "block", type: block.id } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Dónde encontraste esta data ????
Excelente !
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
En la documentación del toolbox hay un apartado de bloques predeterminados
Related #251
Repliqué el bloque que está hoy en producción, que tenga el bloquesito del valor dentro en lugar de el input de número.
La razón por la cuál no estaba andando es porque los bloques de valores tenían hardcodeado que escupan un sting vacío en lugar de un valor.
Aproveché también a cambiar algunos tipos que faltaban.
Grabacion.de.pantalla.desde.01-08-24.14_43_15.mp4