ds_list_read(id, str [, legacy]);
参数 | 描述 |
---|---|
id | The id of the data structure to read into. |
str | The string to read from. |
legacy (optional) | 可以是 true 或 false 或完全省略。 |
返回: N/A(无返回值)
With this function you can recreate a saved ds_list (one that
has previously been written as a string using ds_list_write). You must first
create a new ds_list to read the string into, and if the ds_list
already exists and has information stored in it, then this will be
cleared before reading. This function is of vital importance when
creating save/load mechanisms for your game.Note that if the data
structure was created with previous versions of GameMaker
you should add the optional argument "legacy", setting it to
true as the string format has changed with this
version.
list = ds_list_create();
ini_open("save.ini");
var str = ini_read_string("Lists", "0", "");
if str != ""
{
ds_list_read(list, str);
}
ini_close();
The above code creates a list and stores the index in the variable "list". 然后打开一个ini file并从中读取一个字符串,检查以确保该字符串不会先返回为空。This string is then read into the newly created ds_list.