ds_stack_read

Reads a stack data structure from a string.

语法:

ds_stack_read(id, str [, legacy] );


参数 描述
id The id of the data structure to read into.
str The string to read from.
legacy (optional) 可以是 truefalse 或完全省略。


返回: N/A(无返回值)


描述

With this function you can recreate a saved ds_stack (one that has previously been written as a string using ds_stack_write). You must first create a new ds_stack to read the string into, and if the ds_stack already exists and has information stored in it, then this will be cleared before reading. 在为游戏创建保存/加载机制时,此功能至关重要。请注意,如果数据结构是使用以前的版本创建的GameMaker你应该添加可选参数“legacy”,将其设置为true,因为此版本的字符串格式已更改。


例如:

stack = ds_stack_create();
ini_open("save.ini");
var str = ini_read_string("Stacks", "0", "");
if str != ""
   {
   ds_stack_read(stack, str);
   }
ini_close();

The above code creates a stack and stores the index in the variable "stack". 然后打开一个ini file并从中读取一个字符串,检查以确保该字符串不会先返回为空。This string is then read into the newly created ds_stack.


上一页: Stacks
下一页: ds_stack_write
© Copyright YoYo Games Ltd. 2018 All Rights Reserved