PepperonIT / blockly-site

react app running Blockly
Apache License 2.0
1 stars 0 forks source link

Using variables #22

Closed casperlundberg closed 1 year ago

casperlundberg commented 1 year ago

The children wanted to be able to use variables more, for instance program Pepper to say the answers to math tasks. This can be done via shadow-blocks but field-slider cant be shadowed as far as I understand. For now, I implement shadowing for all blocks where it is possible and then we can discuss how to use field-slider in the scenario

casperlundberg commented 1 year ago

The problem with allowing variables everywhere is that the built-in field constraints (min and max in our case) do not work since the field is replaced by the variable. There is no easy way to check the value of the variable in the codegen either because the block that takes the variable as input only get the variables name. I am looking to se if there is a way to get a variables value from it's name in Blockly but currently have no luck.

casperlundberg commented 1 year ago

Variables works for expressions now. However, they are not typed and trying to make typed variables turned up to be a hassle where the documentation is insufficient...

I can create the typed variable blocks but I haven't found a way to generate a dynamic category for the toolbox which updates when a variable is added (One cannot not use the custom built-in dynamic category named "VARIABLES" because it forces untyped variables)

casperlundberg commented 1 year ago

Variables and shadowblocks for all custom blocks is implemented, still not typed!