عدد مرات صد الكرة

الكتل هي ما تستخدمه للبرمجة. وهي تمثل التعبيرات والعبارات في لغات البرمجة النصية.

للحصول على مزيد من المعلومات حول الوحدات الأساسية وأشكالها، يمكنك مراجعة مسرد المصطلحات المرئي.

حظر التعريف

ويحدّد تعريف الكتلة روابط قطع الألغاز والحقول فيها. ويتم تحديد معظم شكل ونمط القوالب بطرق أخرى. إنّ السلسلة (عادةً ما تكون رمزًا) التي يتم تحويل الحظر إليها هي أداة إنشاء رمز الحظر.

أسهل طريقة لتحديد قوالب بسيطة هي استخدام JSON.

يحدد مقتطف الرمز هذا كتلة "الانتقال للأمام" مع الروابط التالية والسابقة، وحقل واحد للمسافة.

// Create the definition.
const definitions = Blockly.createBlockDefinitionsFromJsonArray([
  {
    // The type is like the "class name" for your block. It is used to construct
    // new instances. E.g. in the toolbox.
    type: 'my_custom_block',
    // The message defines the basic text of your block, and where inputs or
    // fields will be inserted.
    message0: 'move forward %1',
    args0: [
      // Each arg is associated with a %# in the message.
      // This one gets substituted for %1.
      {
        // The type specifies the kind of input or field to be inserted.
        type: 'field_number',
        // The name allows you to reference the field and get its value.
        name: 'FIELD_NAME',
      }
    ],
    // Adds an untyped previous connection to the top of the block.
    previousStatement: null,
    // Adds an untyped next connection to the bottom of the block.
    nextStatement: null,
  }
]);

// Register the definition.
Blockly.defineBlocks(definitions);

مربّع للمضي قدمًا

لمزيد من المعلومات حول طريقة تحديد المجموعات، يمكنك الاطّلاع على مقالة تحديد المجموعات.

للحصول على معلومات حول كيفية تضمين المجموعة في مربع الأدوات، يُرجى الاطّلاع على نظرة عامة على مربع الأدوات.