ds_priority_read

使用此函数,您可以重新创建已保存的DS优先级(以前使用ds_priority_write()作为字符串写入的优先级)。必须首先创建新的DS优先级才能将字符串读入,如果DS优先级已存在并且其中存储有信息,则在读取之前将清除此优先级。为游戏创建保存/加载机制时,此函数至关重要。

请注意,如果指定的DS字符串是GameMaker编写的:Studio 1.2. x运行时(或更早版本),您应该指定可选参数"legacy",将其设置为true,作为之后更改的字符串格式。

 

语法:

ds_priority_read(id, str, [legacy]);

参数类型描述
idDS Priority要写入的数据结构的ID。
strString要从中读取的字符串。
legacyBoolean可选可以为truefalse,也可以完全省略。

 

返回:

N/A

 

例子:

p_queue = ds_priority_create();
ini_open("save.ini");
var str = ini_read_string("P_Queues", "0", "");
if (str != "")
{
    ds_priority_read(p_queue, str);
}
ini_close();

上述代码创建优先级队列并将索引存储在变量"p_queue"中。然后打开ini文件并从中读取字符串,检查以确保字符串不会首先返回为空。然后将此字符串读入新创建的DS优先级。