Octubre 02, 2010, 10:20:46 PM Ultima modificación: Octubre 03, 2010, 05:55:14 PM por Texic
Creador: Yo

Version de GM utilizada:  :GM8:

Descripcion:
CitarEste script exporta e importa rooms del game maker. Tiene algunos peque?os inconvenientes que luego solucionar?. Por ej, no guarda los c?digos de creaci?n del room, ni los c?digos de creaci?n de los objetos. Hay que estar en el room en el que se va a exportar (No pasa lo mismo al importar), aunq esto es f?cil de solucionar, y nada m?s. Lo hice lo m?s completo que pude

room_export
[gml]global.a=file_text_open_write(argument0)
with (all)
{
file_text_write_string(global.a,"room_instance_add(argument0,"+string(x)+","+string(y)+","+string(object_index)+")")
file_text_writeln(global.a)
}
b=1
z=1
while layer<>0
{
for (q=0;q<=room_width;q+=1)
{
for (w=0;w<=room_height;w+=1)
{
l=tile_layer_find(layer,q,w)
if l<>-1 and search()=0
{
l[z]=l
z+=1
file_text_write_string(global.a,"room_tile_add(argument0,"+string(tile_get_background(l))+","+string(tile_get_left(l))+","+string(tile_get_top(l))+","+string(tile_get_width(l))+","+string(tile_get_height(l))+","+string(tile_get_x(l))+","+string(tile_get_y(l))+","+string(layer)+")")
file_text_writeln(global.a)
}
}
}
b+=1
}
file_text_write_string(global.a,"room_set_code(argument0,'room_speed="+string(room_speed)+"')")
file_text_writeln(global.a)
file_text_write_string(global.a,"room_set_width(argument0,"+string(room_width)+")")
file_text_writeln(global.a)
file_text_write_string(global.a,"room_set_height(argument0,"+string(room_height)+")")
file_text_writeln(global.a)
file_text_write_string(global.a,"room_set_caption(argument0,'"+string(room_caption)+"')")
file_text_writeln(global.a)
file_text_write_string(global.a,"room_set_persistent(argument0,"+string(room_persistent)+")")
file_text_writeln(global.a)
file_text_write_string(global.a,"room_set_background_color(argument0,"+string(background_color)+","+string(background_showcolor)+")")
file_text_writeln(global.a)
for (v=0;v<=7;v+=1)
{
file_text_write_string(global.a,"room_set_background(argument0,"+string(v)+","+string(background_visible[v])+","+string(background_foreground[v])+","+string(background_index[v])+","+string(background_x[v])+","+string(background_y[v])+","+string(background_htiled[v])+","+string(background_vtiled[v])+","+string(background_hspeed[v])+","+string(background_vspeed[v])+","+string(background_alpha[v])+")")
file_text_writeln(global.a)
file_text_write_string(global.a,"room_set_view(argument0,"+string(v)+","+string(view_visible[v])+","+string(view_xview[v])+","+string(view_yview[v])+","+string(view_wview[v])+","+string(view_hview[v])+","+string(view_xport[v])+","+string(view_yport[v])+","+string(view_wport[v])+","+string(view_hport[v])+","+string(view_hborder[v])+","+string(view_vborder[v])+","+string(view_hspeed[v])+","+string(view_vspeed[v])+","+string(view_object[v])+")")
file_text_writeln(global.a)
}
file_text_write_string(global.a,"room_set_view_enabled(argument0,"+string(view_enabled)+")")
file_text_close(global.a)[/gml]

room_import
[gml]global.b=file_text_open_read(argument1)
while !file_text_eof(global.b)
{
execute_string(file_text_read_string(global.b),argument0)
file_text_readln(global.b)
}
file_text_close(global.b)[/gml]

search //lo van a necesitar, es un script q usa el export para asegurarse de no repetir los tiles
[gml]t=1
o=0
while l[t]<>0
{if l[t]=l {o=1 break}
t+=1}
return o[/gml]

Ejemplo:[gml]//exportar
layer[1]=1000000 //estos son los layers para los tiles, no encontr? una manera de sacarlos por c?digo, asi que hay que ingresarlos manualmente antes de exportar
layer[2]=999999
room_export("\Rooms\Room1.gmr")
//importar
room_import(room1,"\Rooms\Room1.gmr")[/gml]

Dejo un adjunto obviamente, para demostrar su funcionamiento. Mientras m?s layers haya y m?s tama?o tenga el room, m?s tarda en exportar. Siempre pueden encriptar los archivos resultantes, ya que no vienen encriptados por defecto. Es lo mejor que pude hacer por ahora, pero ya lo iremos mejorando entre todos. Saludos  :)




Buen script si lo uso con gusto te doy los creditos






[gml]global.a=file_text_open_write(argument0)
with (all)
{
file_text_write_string(global.a,"room_instance_add(argument0,"+string(x)+","+string(y)+","+string(object_index)+")")
file_text_writeln(global.a)
}[/gml]
creo que yo  habria usado un for recorriendo todo el room pixel por pixel (no se por que) y seria realmente leeeento

De hecho lo hace para los tiles (No encontr? otra forma de hacerlo)