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) Can be either true or false or omitted completely.

返回: 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. 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.


stack = ds_stack_create();
var str = ini_read_string("Stacks", "0", "");
if str != ""
   ds_stack_read(stack, str);

The above code creates a stack and stores the index in the variable "stack". It then opens an ini file and reads a string from that, checking to make sure that the string is not returned as empty first. This string is then read into the newly created ds_stack.

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