<div style="clear: both;">First initialize an array to decide which objects to save the positions of (those objects who are moving):
//Which objects to draw
nr_obj = 3; //How many objects
obj_d[0] = object0;
obj_d[1] = object1;
obj_d[2] = object2;
obj_d[3] = object3;
And then next thing would be to save their position into (preferably) an external file, just like this:
i = 0;
d = 0;
while(i<instance_number(obj_d[d])) {
//Selecting information
x_id = (instance_find(obj_d[d],i).x;
y_id = (instance_find(obj_d[d],i).y;
file = file_text_open_append(object_get_name(object_index)
+string(instance_find(obj_d[d],i));
file_text_write(file,x_id);
file_text_writeln(file);
file_text_write(file,y_id);
file_text_close(file);
i +=1;
if (i==instance_number(obj_d[d])) {
d += 1;
i = 0;
}</div>
You might want to save other stuff too, like image_single, health, time etc. but this is the basic. It saves the position of all moving object such that you may later recreate the same thing using those variables.
Easiest way to recreate it, and by doing so creating a visual replay of an earlier situation, is by adding the same objects as in the real room, to the review room and then in each of the review objects let them read their positions like this (event):
y = file_text_read_string(file);
file_text_writeln();
x = file_text_read_string(file);
file_text_writeln();
The tricky thing is in the create event, where we will have to open… the correct file. To make this easier we created one file per object and we save them as the object name plus their id. The id was to make the file unique in case there are several instances of the same object.
As the different instances in the review room are visually equal it doesn’t matter which read from which, as long as two instances doesn’t read from the same file. There are several solutions to this, I suppose. The one I came up with is to change the name of the file as it is selected. This will make it unselect able for other instances. So in create event:
file = false;
file_r = file_find_first(working_directory+"*.*",fa_archive)
while(file==false) {
if (string_pos("rev_"+string(object_get_name(object_index)),file_r)) {
file = true
}
if (file==false) {
file_r = file_find_next();
}
if (file_r==""
{file = true;
show_message("Couldn’t find a file for this object"
;}
}
Good luck with this script. If you have any problem, please tell me so and I will correct it and explain it.
Comments
Loading comments...