Repository: 4ian/GDevelop
File: GDJS/GDJS/Extensions/Builtin/AdvancedExtension.cpp (C++)

Code before:
            gd::ExpressionCodeGenerator::GenerateExpressionCode(
                codeGenerator, context, "string",
                instruction.GetParameter(0).GetPlainString());

        gd::String operatorString = instruction.GetParameter(1).GetPlainString();

        gd::String operandCode =
            gd::ExpressionCodeGenerator::GenerateExpressionCode(
                codeGenerator, context, "number",
                instruction.GetParameter(2).GetPlainString());

        gd::String resultingBoolean =
            codeGenerator.GenerateUpperScopeBooleanFullName("isConditionTrue", context);

        return resultingBoolean + " = " +
               gd::String(instruction.IsInverted() ? "!" : "") +
               codeGenerator.GenerateRelationalOperation(
                   operatorString,
                   "((typeof eventsFunctionContext !== 'undefined' ? "
                   "Number(eventsFunctionContext.getArgument(" +
                       parameterNameCode + ")) || 0 : 0)",
                   operandCode) +
               ");\n";
      });

  GetAllConditions()["CompareArgumentAsString"]
      .SetCustomCodeGenerator([](gd::Instruction &instruction,
                                 gd::EventsCodeGenerator &codeGenerator,
                                 gd::EventsCodeGenerationContext &context) {
        gd::String parameterNameCode =
            gd::ExpressionCodeGenerator::GenerateExpressionCode(
                codeGenerator, context, "string",
                instruction.GetParameter(0).GetPlainString());

        gd::String operatorString = instruction.GetParameter(1).GetPlainString();

        gd::String operandCode =
            gd::ExpressionCodeGenerator::GenerateExpressionCode(
                codeGenerator, context, "string",
                instruction.GetParameter(2).GetPlainString());

        gd::String resultingBoolean =
            codeGenerator.GenerateUpperScopeBooleanFullName("isConditionTrue", context);

        return resultingBoolean + " = " +
               gd::String(instruction.IsInverted() ? "!" : "") +
               codeGenerator.GenerateRelationalOperation(
                   operatorString,
                   "((typeof eventsFunctionContext !== 'undefined' ? "
                   "\"\" + eventsFunctionContext.getArgument(" +
                       parameterNameCode + ") : \"\")",

Review comment (suggestion):
The opening parenthesis was in the `leftOperand` parameter. While it was working, it's now easier to follow.

Code after:

        return "\"\" + eventsFunctionContext.getArgument(" + parameterNameCode +
               ")";
      });

  GetAllConditions()["CompareArgumentAsNumber"]
      .SetCustomCodeGenerator([](gd::Instruction &instruction,
                                 gd::EventsCodeGenerator &codeGenerator,
                                 gd::EventsCodeGenerationContext &context) {
        gd::String parameterNameCode =
            gd::ExpressionCodeGenerator::GenerateExpressionCode(
                codeGenerator, context, "string",
                instruction.GetParameter(0).GetPlainString());

        gd::String operatorString = instruction.GetParameter(1).GetPlainString();

        gd::String operandCode =
            gd::ExpressionCodeGenerator::GenerateExpressionCode(
                codeGenerator, context, "number",
                instruction.GetParameter(2).GetPlainString());

        gd::String resultingBoolean =
            codeGenerator.GenerateUpperScopeBooleanFullName("isConditionTrue", context);

        return resultingBoolean + " = " +
               gd::String(instruction.IsInverted() ? "!" : "") + "(" +
               codeGenerator.GenerateRelationalOperation(
                   operatorString,
                   codeGenerator.HasProjectAndLayout()
                       ? "0"
                       : "(Number(eventsFunctionContext.getArgument(" +
                             parameterNameCode + ")) || 0)",
                   operandCode) +
               ");\n";
      });

  GetAllConditions()["CompareArgumentAsString"]
      .SetCustomCodeGenerator([](gd::Instruction &instruction,
                                 gd::EventsCodeGenerator &codeGenerator,
                                 gd::EventsCodeGenerationContext &context) {
        gd::String parameterNameCode =
            gd::ExpressionCodeGenerator::GenerateExpressionCode(
                codeGenerator, context, "string",
                instruction.GetParameter(0).GetPlainString());

        gd::String operatorString = instruction.GetParameter(1).GetPlainString();

        gd::String operandCode =
            gd::ExpressionCodeGenerator::GenerateExpressionCode(
                codeGenerator, context, "string",
                instruction.GetParameter(2).GetPlainString());