第二种类型的错误是编译器错误。当游戏遇到语法检查器可能无法检测到的错误时,就会发生编译器错误-很容易忘记声明变量或错误地将字符串输入为真实的,例如-或者当错误与您如何从目标平台的平台首选项设置编译工具有关时。这些错误将被GameMaker捕获当游戏正在编译时,此信息也将显示在编译器错误输出中,如下所示:
注意 这些错误通常不会弹出一个窗口,只会在编译器输出中显示 "Build Failed"。如果弹出一个窗口,则通常是运行程序错误, 此处 对此进行解释。
编译器错误消息都将遵循相同的格式:
[object] - [event] - [Line Number]: [error string]
如果在脚本中发现错误,那么它将简单地:
[script] - [Line Number]: [error string]
然后,您可以双击任何编译器错误条目,以在标记为给出错误的位置打开给定资产,然后您可以使用消息中包含的信息来精确定位对象或脚本中发生错误的位置。然而,有时这些错误看起来有点神秘,所以下面你可以找到所有错误的完整列表和它们的含义的简要解释:
错误(Error) | 描述 |
---|---|
其他 | |
No program to compile | A previous compile error has caused the compiler parse tree to not be created and thus the compiler has no program data to compile |
Fatal Error while compiling [name] - bailing details below | This message simply means that some error has been discovered but the compiler cannot place what or where (if this happens consistently you may wish to contact support and supply the details that the compiler output window shows) |
Recursive macro expansion is not supported | You have used recursive macros that refer to each other and constantly expand |
Unable to find TextureGroup [group] | This error is usually only found from trying to run a malformed project file (if this happens consistently you may wish to contact support and supply the details that the compiler output window shows) |
Wrong to convert [value] to number | You have tried to convert the given value, for example a string, into a number |
Division by 0 | You have tried to divide a value by 0 |
Invalid object id [object ID] used | You have tried to access an object using an ID value that is incorrect |
Unclosed comment (/*) at end of script | You have created a script comment using /* [comment] */ but have not supplied the closing comment tag |
Invalid token | You have an invalid character in your game code, which can happen with foreign language characters or Unicode |
Number [num] in incorrect format | The given number - shown in the error - is not the correct format for the function or operation being performed, for example you supply an integer when a pointer is required |
Unexpected EOF encountered | You have reached the end of file unexpectedly while using the File Functions |
字符串 | |
Unable to Not a string | You have tried to use "!" (not) on a string |
Unable to Negate a string | You have tried to negate a string, for example string = -string |
函数、函数和参数 | |
Wrong number of arguments for function [function] | You have supplied too many or too few arguments for the given function |
Failed to parse action_execute_script() - incorrect number of arguments received | The GML Visual action Execute Script has too many or too few arguments for the given script being called |
Unknown function [function] check to see if script is empty | A script or function has been called that the compiler does not recognise (this error is usually thrown by empty script asset references since the compiler will strip out these assets on compile) |
Function [function] expects n arguments, a provided | A function has been given the wrong number of arguments (n) when a certain number were expected (a) |
Assignment of an empty value (function does not return anything?) | You have tried to assign a return value from a function when that function returns nothing |
Unable to find function [function] | You have called an unknown function |
Calling a function that needs an instance and no instance is available | The function or script being called is for acting on an instance, but at the time of running no instances exist |
Calling a function that needs an other and no other is available | You have used the keyword other outside of the Collision Event or outside of a with statement |
Argument naming error, n arguments but no reference found to a | You have given a number of arguments to a script, but fail to reference one of them in the script, for example, your script takes three arguments but you only use arguments n and a |
Cannot compare arguments | You have tried to compare two different argument types, like a string and a real number |
Unknown function or script [functions/script] | The compiler does not recognise the function or script being called |
Cannot use resource name [resource] as it is not being exported | You have tried to access a resource that has not been flagged as part of the project for the platform being compiled to |
Cannot use function/script name for a variable, using [functions/script] | You have tried to use either a function name or a script name as a variable, for example: string = "Hello World" |
Cannot use an argument outside a script | The built in argument variables can only be used inside a script but you have tried to use them elsewhere |
No references to argument[num] but references argument[num] | You are using a reference to an argument that does not exist but that could map to another argument |
Incorrect number of arguments for accessor | You have supplied the wrong number of arguments when using an accessor |
Wrong type of arguments for (one of the below): /, div, mod, +, -, &&, ||, &, |, ^, <<, >> | You have supplied the wrong type of argument for the expression being evaluated |
变量 | |
Using uninitialized variable [var] | You have tried to use the named variable before it has been initialised |
Variable [var] is read-only | You have tried to change the named variable when it cannot be changed |
Unable to find variable named [var] | The named variable cannot be found in the current compile |
Malformed variable reference | You have tried to reference a variable in the wrong way |
Trying to set a read only variable [var] | You have tried to set a variable that is read only |
Cannot re-declare a built in variable | You have tried to declare a local variable using the same name as one of the built in variables |
Cannot use resource name for a variable | You have use the same name as a resource from the resource tree as a local variable |
[Variable] is read-only | You have tried to use a variable that has been flagged as read only |
常量 | |
Cannot set a constant [constant] to a value | You have tried to set a constant to a different value |
Constant is invalid here | You have tried to use a constant somewhere that is not valid for the code being run |
Cannot assign to [var] - it's a constant | You have tried to assign a new value to the named constant |
数组 | |
Array index should not be negative | You have tried to access, create, or set an array value using a negative array index |
格式错误 | |
Malformed Conditional operator | You have used an erroneous conditional (ternary) operator or if statement, and not the format: [condition] ? [expression1] : [expression2]; |
If requires a then statement | You have written an if statement and expression to evaluate, but not given any then part to run |
malformed assignment statement | In the code you are using an assignment operator wrong |
Malformed if / repeat / while / do / for / with / switch / break / continue / exit statement | The structure of the given statement is incorrect. |
Malformed post inc or dec statement | You have tried to use [var]++ or [var]-- in an illegal way |
Malformed pre inc or dec statement | You have tried to use ++[var] or --[var] in an illegal way |
Malformed global gml_pragma | You have created a wrong global string when using gml_pragma |
Malformed PNGCrush gml_pragma | You have created a wrong string command for PNGCrush when using gml_pragma |
Malformed Texgroup.Scale gml_pragma | You have create a wrong global string when using gml_pragma |
Switch / Case | |
Default cannot be used multiple times in a switch | In your switch statement you have defined default: more than once |
Clause expression type mismatch (clause expressions should all be the same type) | In your switch you are checking for two different constant case types, for example a string in one case and an integer in another |
Case argument should be a constant | You have tried to use a value that does not evaluate to a constant within one of your switch cases |
Statement in a switch MUST appear after case or default | You have added a statement to a switch outside of either a case: or default: call |
Duplicate case statement found / original here | You have used the same case constant in two different places within a switch (note that the "original here" comment will be on another line and can be clicked to show the original case) |
表达式 | |
No return value from expression (does expression have a return value?) | You have tried to assign a return value from an expression to a variable when the expression returns nothing |
Expecting expression after the '.' | You have used the point "." notation erroneously and not added an expression afterwords correctly |
Unexpected symbol [symbol] in expression | The expression uses a symbol that is not part of the accepted expression symbol set - the symbol in question will be shown |
未知运算符 | |
Unknown Pre operator | You have tried to use a symbol as a pre-operator when that symbol is not permitted, for example **[var] or >>[var] - only ++ and -- are acceptable |
Unknown Post operator | You have tried to use a symbol as a post-operator when that symbol is not permitted, for example [var]** or [var]>> - only ++ and -- are acceptable |
Unknown pragma [gml_pragma string] | You have used a pragma string that is unknown to the compiler |
Unknown unary operator | You have tried to use an unknown symbol as a unary operator |
Unknown binary operator | You have tried to use an unknown symbol as a binary operator |
Unknown operator [operator] | You have tried to use an unknown symbol as an operator (the symbol will be shown in the error) |
Break / Continue | |
Break used without context | You have not used break within a switch or a loop or any other permitted structure |
Continue used without context | You have not used continue within the correct context |
continue statement is not allowed at this point | You have used continue within a apart of your code where it is not permitted |
枚举 | |
enum num is invalid | The enum number is invalid for the enum |
malformed enum | You have not created the enum correctly |
enum [enum] has already been defined | You have tried to define an enum using the same name as another previously defined |
malformed enum entry | The enum has an invalid entry |
enum expression must be an integer constant | The enum entry does not evaluate as an integer constant |
enum reference [key] does not exist in [enum] | You have tried to reference an enum entry using a key that has not previously been defined for that enum |
预期符号/值 | |
Symbol ( expected Symbol ) expected Symbol , or ) expected Symbol { expected Symbol } expected Symbol , or } expected Symbol : expected Symbol ; expected Symbol [ expected symbol ] expected Symbol , or ] expected | You have not used a required symbol when writing your code |
Expected id or string | You have used a value that is not either a layer ID or a layer name - as a string - in one of the Layer functions |
keyword Until expected | You have created a do... until loop but neglected to supply an until expression |
Function name expected | You have used something other than a function name in your code where a function should go |
variable name expected | You have supplied a name that is not a variable name where one is expected |
Assignment operator expected | You have created an assignment which expects an operator but none has been supplied |
Android独有 | |
Android ARM ToolChain directory [dir] does not exist | The link given in the Android Preferences for the ARM toolchain is incorrect and does not exist. |
Android MIPS ToolChain directory [dir] does not exist | The link given in the Android Preferences for the MIPS toolchain is incorrect and does not exist. |
Android x86 ToolChain directory [dir] does not exist | The link given in the Android Preferences for the x86 toolchain is incorrect and does not exist. |
Android NDK directory [dir] does not exist | The link given in the Android Preferences for the Android NDK is incorrect and does not exist. |
Windows独有 | |
Configuration Problem : Windows Visual Studio Path needs to be set to point to Visual Studio (.bat) batch file. | The link given in the Windows Preferences for the Visual Studio (.bat) batch file is incorrect and does not exist. |