运行器错误

即使在代码编辑器中进行了语法检查,然后让编译器检查代码中的编译器错误之后,仍然有可能出现错误的情况。在大多数情况下,这将抛出一个虚拟机(VM)运行程序错误(也称为运行时异常) ,它看起来像这样:

Runner Error Window
Caption

运行程序错误通常比编译错误更严重,因为它意味着代码出现了代码编辑器和编译器都无法检测到的严重错误,因此您应该注意所有这类错误。当出现错误时,您可以使用弹出窗口上的 Copy 按钮将错误复制到剪贴板,然后将其粘贴到文本文件(或其他地方)中以供将来参考。

这一错误的结构如下:

如上所述,某些错误消息将不通过实例 ID 值而是通过值来标识范围。这些值可以用来确定错误的确切性质,以及它与下列可能值的关系:

前缀范围
-1Self
-2Other
-3All
-4Noone
-5Global
-6Not Specified
-7Local

 

VM 运行程序可能出现的错误如下:

错误(Error)信息类型描述
DoSetInvalid comparison type数据类型This denotes that the runner has tried to compare two incompatible data types, like a real number with a string.
DoConvExecution 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.

DoAddExecution Error数学Something has gone wrong when using the addition (+) expression.
DoMulExecution Error数学Something has gone wrong when using the multiplication (*) expression.
DoSubExecution Error数学Something has gone wrong when using the subtraction (-) expression.
DoSubExecution Engine - Cannot operate on string type数学You are trying to subtract the wrong type of variables (for example subtract a string from a real).
DoDivExecution Error数学Something has gone wrong when using the division (/ or div) expression.
DoDivExecution Engine - Cannot operate on string type数学You are trying to divide the wrong type of variables (for example divide a string by a real).
DoDivDivide 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)
DoModExecution Error数学Something has gone wrong when using the modulo (mod) expression.
DoModExecution 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).

DoAndExecution Error位操作Something has gone wrong when using the bitwise "and" (&) expression.
DoAndExecution 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).
DoOrExecution Error位操作Something has gone wrong when using the bitwise "or" (|) expression.
DoOrExecution 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).
DoXorExecution Error位操作Something has gone wrong when using the bitwise "xor" (^) expression.
DoXorExecution 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).
DoShlExecution Error位操作Something has gone wrong when bitshifting left (<<) a value.
DoShlExecution Engine - Cannot operate on string type位操作You are trying to left bitshift (<<) the wrong type of variables (for example trying to bitshift a string).
DoShrExecution Error位操作Something has gone wrong when bitshifting right (>>) a value.
DoShrExecution Engine - Cannot operate on string type位操作You are trying to right bitshift (>>) the wrong type of variables (for example trying to bitshift a string).

DoNegExecution ErrorNegateYou are trying to turn a variable type into a negative when this type does not permit such an operation.
DoNotExecution ErrorNegateYou are trying to "not" a variable type when this type does not permit such an operation.

PushExecution Error - Variable Index out of range (var)堆栈The variable being accessed is out with the established range for the runner.
PushVariable Get (var)堆栈The given variable has not been defined or is unknown.
PopVariable Index out of range (var)堆栈The variable being accessed is out with the established range for the runner.
PopVariable Get (var)堆栈The given variable has not been defined or is unknown.

WithCannot use global in with statementWithYou have tried to use "global" as a variable within a "with" statement, ie:
with (global)
   {
   //do something;
   }
WithCannot use local in with statementWithYou have tried to use "local" as a variable within a "with" statement, ie:
with (local)
   {
   //do something;
   }

DoCallExecution Engine type errorEngineThis 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-EngineA 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 VariableVariable not set before reading itVariable InitialisationYou 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.