I have therefore created a script that creates an overview of your game's inheritance at run time. It lists the inheritance in a simple text file. Parent objects are marked with a +, objects without children with a -. Children are listed below their parents at a certain indentation, into any required level of depth.
How to use
- Copy / paste the script in your project.
- Run the game in Windows debug mode (it doesn't work in HTML5).
- In the debug window, execute the script.
var i,n,objects,tree,levels,level,pos,fn,f,parent,lead;// Find maximum object ID to look forn=object_add();object_delete(n);// File to write inheritance tofn='inheritance.txt';objects=ds_list_create();tree=ds_list_create();levels=ds_list_create();// Create list of objectsfor (i=0; i<n; i+=1) if (object_exists(i)) ds_list_add(objects,i);// Create root list of objectsfor (i=ds_list_size(objects)-1; i>=0; i-=1) { n=ds_list_find_value(objects,i); if (object_get_parent(n)<0) { ds_list_add(tree,n); ds_list_add(levels,0); ds_list_delete(objects,i); } }// And now add to levelswhile (ds_list_size(objects)!=0) { for (i=ds_list_size(objects)-1; i>=0; i-=1) { n=ds_list_find_value(objects,i); parent=object_get_parent(n); // Is the parent on the list? pos=ds_list_find_index(tree,parent); if (pos>=0) { // Yes: get the level of the parent and add one level=ds_list_find_value(levels,pos); // Add below the parent ds_list_insert(tree,pos+1,n); ds_list_insert(levels,pos+1,level+1); ds_list_delete(objects,i); } } } // Create the fileif (file_exists(fn)) file_delete(fn);f=file_text_open_write(fn);file_text_write_string(f,'OBJECT INHERITANCE SCHEME');file_text_writeln(f);// Iterate through the lists and write contentsfor (i=0; i<ds_list_size(tree); i+=1) { n=ds_list_find_value(levels,i); if (n=0) file_text_writeln(f); if (ds_list_find_value(levels,i+1)>n) lead='+' else lead='-'; repeat (n) file_text_write_string(f,' '); file_text_write_string(f,lead+' '+object_get_name(ds_list_find_value(tree,i))); file_text_writeln(f); } // The end file_text_close(f);ds_list_destroy(objects);ds_list_destroy(tree);ds_list_destroy(levels);execute_shell('notepad.exe',fn);
Edited by Smarty, 08 November 2011 - 04:43 PM.











