Game Maker Studio:DoSet ::无效的比较类型

时间:2015-04-02 00:12:05

标签: game-maker gml

___________________________________________
############################################################################################
FATAL ERROR in
action number 4
of Create Event
for object eng_Global:

DoSet :: Invalid comparison type
 at gml_Script_Data_Load (line 1) - ///Data_Load()
############################################################################################
--------------------------------------------------------------------------------------------
stack frame is
gml_Script_Data_Load (line 1)
called from - gml_Object_eng_Global_CreateEvent_4 (line 60) - Data_Load();

我在评论中得到此错误,而不是实际的if语句,我无法在不注释Data_Load()的情况下绕过此错误,这是加载用户的原因。数据

我最近更新到版本1.4.1567,也许这是此版本中的错误。

我应该声明"已连接"和"访客"变量都是整数(布尔值),并且不会在代码中的任何位置设置为字符串。

这是Data_Load()脚本:

///Data_Load()
if (Connected && !Guest) {

ini_open(User_Name+"_NSD_Temp.ini");

// Base Statistics
Level = ini_read_real("Statistics","Level",Level);
Exp_Total = ini_read_real("Statistics","Experience_Total",Exp_Total);
Exp = ini_read_real("Statistics","Experience",Exp);
Exp_Left = ini_read_real("Statistics","Experience_Left",Exp_Left);
Exp_Max = ceil(Level*5);
Gold = ini_read_real("Statistics","Gold",Gold);
Gold_Total = ini_read_real("Statistics","Gold_Total",Gold_Total);
Karma = ini_read_real("Statistics","Karma",Karma);
Karma_Total = ini_read_real("Statistics","Karma_Total",Karma_Total);
Highscore = ini_read_real("Statistics","Highscore",Highscore);

Weapons_Inv_Length = ini_read_real("Statistics","Weapons_Inv_Length",Weapons_Inv_Length);
Stones_Inv_Length = ini_read_real("Statistics","Stones_Inv_Length",Stones_Inv_Length);
Stone_Slots_Owned = ini_read_real("Statistics","Stones_Slots_Owned",Stones_Slots_Owned);

// Game
Ninja_Name = ini_read_string("Game","Ninja_Name",Ninja_Name);
Ninja_Level = ini_read_real("Game","Ninja_Level",Ninja_Level);
Ninja_Health = ini_read_real("Game","Ninja_Health",Ninja_Health);
Ninja_Health_Max = ini_read_real("Game","Ninja_Health_Max",Ninja_Health_Max);
Ninja_Health_Regen_Upgrade = ini_read_real("Game","Ninja_Health_Regen_Upgrade",Ninja_Health_Regen_Upgrade);
Ninja_Health_Regen = Ninja_Health_Base*(Ninja_Health_Regen_Upgrade)/room_speed;
Ninja_Weapon = ini_read_real("Game","Ninja_Weapon",Ninja_Weapon);
Ninja_Colour = ini_read_real("Game","Ninja_Colour",Ninja_Colour);
Ninja_Power = ini_read_real("Game","Ninja_Power",Ninja_Power);
Ninja_Max_Speed = ini_read_real("Game","Ninja_Max_Speed",Ninja_Max_Speed);
Ninja_Attack_Speed = ini_read_real("Game","Ninja_Attack_Speed",Ninja_Attack_Speed);

// Weapons Inventory
for (i=0; i<Weapons_Inv_Length; i++) {
    Weapons_Inv[i,0] = i;
    Weapons_Inv[i,1] = ini_read_real("Weapons Inventory","Inv_Slot_"+string(i),0);
    Weapons[Weapons_Inv[i,1],5] = ini_read_real("Weapons Inventory","Inv_Slot_"+string(i)+"_Owned",Weapons[Weapons_Inv[i,1],5]);
}

// Stones Inventory
for (i=0; i<Stones_Inv_Length; i++) {
    Stones_Inv[i,0] = i;
    Stones_Inv[i,1] = ini_read_real("Stones Inventory","Inv_Slot_"+string(i),0);
    Stones[Stones_Inv[i,1],5] = ini_read_real("Stones Inventory","Inv_Slot_"+string(i)+"_Owned",Stones[Stones_Inv[i,1],5]);
}

// Equipped Stones
for (i=0; i<Stone_Slots_Owned; i++) {
    Stone_Slots[i,0] = i;
    Stone_Slots[i,1] = ini_read_real("Stones Equipped","Slot_"+string(i),Stone_Slots[i,1]);
}

// Costume Colours
for (i=0; i<array_height_2d(Colours); i++) {
    Colours[i,5] = ini_read_real("Costume Colours",Colours[i,1],Colours[i,5]);
}

// Stats
Stat_Clouds_Clicked = ini_read_real("Stats","Clouds_Clicked",Stat_Clouds_Clicked);
Stat_Stars_Clicked = ini_read_real("Stats","Stars_Clicked",Stat_Stars_Clicked);

// Options
SoundFX = ini_read_real("Options","SoundFX",SoundFX);

// Version
Save_Version = ini_read_string("Version","Current",Save_Version);

// Resets
ForceResets = ini_read_string("External","Force_Resets",Force_Resets);

ini_close();

if (ForceResets != Force_Resets) {
    Data_Erase();
}

Data_Submit();

} // If Connected & Not Guest

1 个答案:

答案 0 :(得分:0)

GM的编译器总是很奇怪这些线路错误。它通常不会将空行计为实际行。

如果您针对该问题进行了调整,那么抛出错误的实际代码就是:

if (ForceResets != Force_Resets) {

也许它并不像你基本上要求&#34;如果某些东西不等于它自己&#34; ,这几乎没有意义。该语句将始终评估为false,因此您应该将其删除。

看到你没有在任何这些变量上声明var,那么你就是在操作调用此脚本的实例上的变量。如果某个ForceResets脚本变量和调用实例上的ForceResets变量,那么整个事情可能就是一个命名问题。我也是假设因为你打电话:

ForceResets = ini_read_string("External","Force_Resets",Force_Resets);

第三个参数未在此脚本中的任何位置声明。

总而言之,我说你需要稍微清理一下这个脚本。

专业提示:99%的时间使用for(var i = 0; ...代替for(i = 0。否则,您将使用永远不会使用的i变量离开此实例。