即使在代码编辑器中进行了语法检查,然后让编译器检查代码中的编译器错误之后,仍然有可能出现错误的情况。在大多数情况下,这将抛出一个虚拟机(VM)运行程序错误(也称为运行时异常) ,它看起来像这样:
运行程序错误通常比编译错误更严重,因为它意味着代码出现了代码编辑器和编译器都无法检测到的严重错误,因此您应该注意所有这类错误。当出现错误时,您可以使用弹出窗口上的 Copy 按钮将错误复制到剪贴板,然后将其粘贴到文本文件(或其他地方)中以供将来参考。
这一错误的结构如下:
如上所述,某些错误消息将不通过实例 ID 值而是通过负值来标识范围。这些值可以用来确定错误的确切性质,以及它与下列可能值的关系:
前缀 | 范围 |
---|---|
-1 | Self |
-2 | Other |
-3 | All |
-4 | Noone |
-5 | Global |
-6 | Not Specified |
-7 | Local |
VM 运行程序可能出现的错误如下:
错误(Error) | 信息 | 类型 | 描述 |
---|---|---|---|
DoSet | Invalid comparison type | 数据类型 | This denotes that the runner has tried to compare two incompatible data types, like a real number with a string. |
DoConv | Execution Error | 数据类型 | This denotes an error in the conversion of one data-type into another. |
Argument Type | (function) argument (index) incorrect type (wrong_type) expecting a (expected_type) | 数据类型 | A value with the wrong data type was passed as an argument to the function at (index) (where an index of 1 is the first argument). A value of wrong_type was given but it should be one of expected_type instead. |
DoAdd | Execution Error | 数学 | Something has gone wrong when using the addition (+) expression. |
DoMul | Execution Error | 数学 | Something has gone wrong when using the multiplication (*) expression. |
DoSub | Execution Error | 数学 | Something has gone wrong when using the subtraction (-) expression. |
DoSub | Execution Engine - Cannot operate on string type | 数学 | You are trying to subtract the wrong type of variables (for example subtract a string from a real). |
DoDiv | Execution Error | 数学 | Something has gone wrong when using the division (/ or div) expression. |
DoDiv | Execution Engine - Cannot operate on string type | 数学 | You are trying to divide the wrong type of variables (for example divide a string by a real). |
DoDiv | Divide by zero | 数学 | You are attempting to divide by 0 (note this will only happen when using integer division, dividing a (non-zero) real by 0 will give infinity as an answer, dividing zero by zero will give NaN as an answer). You can check for these values with (is_infinity) and (is_nan) |
DoMod | Execution Error | 数学 | Something has gone wrong when using the modulo (mod) expression. |
DoMod | Execution Engine - Cannot operate on string type | 数学 | You are trying to use modulo (mod) on the wrong type of variables (for example mod a string by a real). |
DoAnd | Execution Error | 位操作 | Something has gone wrong when using the bitwise "and" (&) expression. |
DoAnd | Execution Engine - Cannot operate on string type | 位操作 | You are trying to use bitwise "and" (&) on the wrong type of variables (for example trying to "and" a string with a real). |
DoOr | Execution Error | 位操作 | Something has gone wrong when using the bitwise "or" (|) expression. |
DoOr | Execution Engine - Cannot operate on string type | 位操作 | You are trying to use "or" (|) on the wrong type of variables (for example trying to "or" a string with a real). |
DoXor | Execution Error | 位操作 | Something has gone wrong when using the bitwise "xor" (^) expression. |
DoXor | Execution Engine - Cannot operate on string type | 位操作 | You are trying to use "xor" (^) on the wrong type of variables (for example trying to "xor" a string with a real). |
DoShl | Execution Error | 位操作 | Something has gone wrong when bitshifting left (<<) a value. |
DoShl | Execution Engine - Cannot operate on string type | 位操作 | You are trying to left bitshift (<<) the wrong type of variables (for example trying to bitshift a string). |
DoShr | Execution Error | 位操作 | Something has gone wrong when bitshifting right (>>) a value. |
DoShr | Execution Engine - Cannot operate on string type | 位操作 | You are trying to right bitshift (>>) the wrong type of variables (for example trying to bitshift a string). |
DoNeg | Execution Error | Negate | You are trying to turn a variable type into a negative when this type does not permit such an operation. |
DoNot | Execution Error | Negate | You are trying to "not" a variable type when this type does not permit such an operation. |
Push | Execution Error - Variable Index out of range (var) | 堆栈 | The variable being accessed is out with the established range for the runner. |
Push | Variable Get (var) | 堆栈 | The given variable has not been defined or is unknown. |
Pop | Variable Index out of range (var) | 堆栈 | The variable being accessed is out with the established range for the runner. |
Pop | Variable Get (var) | 堆栈 | The given variable has not been defined or is unknown. |
With | Cannot use global in with statement | With | You have tried to use "global" as a variable within a "with" statement, ie: with (global) { //do something; } |
With | Cannot use local in with statement | With | You have tried to use "local" as a variable within a "with" statement, ie: with (local) { //do something; } |
DoCall | Execution Engine type error | Engine | This is an undefined error within the Virtual Machine. You should file a bug report should this happen (see: The Help Menu for details on how to do this. |
Stack Overflow | - | Engine | A stack overflow occurs when too much memory is used on the call stack and when your game attempts to use more space than is available on the call stack (that is, when it attempts to access memory beyond the call stack's bounds, which is essentially a buffer overflow), the stack is said to overflow, resulting in a program crash. Restart your computer and GameMaker and if the error persists please get in touch with support and/or file a bug (as explained above). |
Read Variable | Variable not set before reading it | Variable Initialisation | You are trying to access a variable that hasn't been set (i.e. initialised) yet. Assign a value to it first before trying to read it, e.g. variable = 100;. Only declaring a variable, using e.g. var variable; will also throw this error. |