Legacy GM Saving a my_room.gmx file from within running game.

M

mccordinator

Guest
I'm trying to see if there is a way to, from within my running game, save a .gmx file of my room after I have dynamically populated it with tiles and collision objects. This data will never change during the course of the game, so I'd like to be able to have it baked in when we are ready to finish up the project.

We don't want to use the internal room editor, so we have it setup to allow us to build a room in GMare, export it to our GMS 1.4 project, and have a script that places appropriate collider objects depending on the depth of the tiles and then tries to minimize the number of collider objects by stretching one object over other colliders and destroying those colliders. Would rather not have this being generated dynamically during the game, as other things will need to be generated dynamically.

Anyone ever attempted or been successful in this??
 

KurtBlissZ

Member
It's not that hard but time consuming.

I never tried this specifically but I have generated levels using strings, then I paste them into the room creation code.

for example

Code:
var _level_string = "";

var _save_type = 0;

with all {
    _level_string += "instance_create("
        +string(x)+","+string(y)+","+string(object_get_name(object_index))+");#";
}

if _save_type {
    clipboard_set_text(_level_string);
}

else {
    var _file = file_text_open_write(get_save_filename('',''));
    file_text_write_string(_file,_level_string);
    file_text_close(_file);
  
}

If you wanted to do this as a room.gmx file.. You could do the same thing using basically the same method.. To import the file you could just name the file then drag it into the IDE

Here's a .room.gmx file just for reference:
<!--This Document is generated by GameMaker, if you edit it by hand then you do so at your own risk!-->
<room>
<caption></caption>
<width>1024</width>
<height>768</height>
<vsnap>32</vsnap>
<hsnap>32</hsnap>
<isometric>0</isometric>
<speed>30</speed>
<persistent>0</persistent>
<colour>12632256</colour>
<showcolour>-1</showcolour>
<code>// room creation code</code>
<enableViews>0</enableViews>
<clearViewBackground>-1</clearViewBackground>
<clearDisplayBuffer>-1</clearDisplayBuffer>
<makerSettings>
<isSet>0</isSet>
<w>0</w>
<h>0</h>
<showGrid>0</showGrid>
<showObjects>0</showObjects>
<showTiles>0</showTiles>
<showBackgrounds>0</showBackgrounds>
<showForegrounds>0</showForegrounds>
<showViews>0</showViews>
<deleteUnderlyingObj>0</deleteUnderlyingObj>
<deleteUnderlyingTiles>0</deleteUnderlyingTiles>
<page>0</page>
<xoffset>0</xoffset>
<yoffset>0</yoffset>
</makerSettings>
<backgrounds>
<background visible="-1" foreground="0" name="" x="0" y="0" htiled="-1" vtiled="-1" hspeed="0" vspeed="0" stretch="0"/>
<background visible="0" foreground="0" name="" x="0" y="0" htiled="-1" vtiled="-1" hspeed="0" vspeed="0" stretch="0"/>
<background visible="0" foreground="0" name="" x="0" y="0" htiled="-1" vtiled="-1" hspeed="0" vspeed="0" stretch="0"/>
<background visible="0" foreground="0" name="" x="0" y="0" htiled="-1" vtiled="-1" hspeed="0" vspeed="0" stretch="0"/>
<background visible="0" foreground="0" name="" x="0" y="0" htiled="-1" vtiled="-1" hspeed="0" vspeed="0" stretch="0"/>
<background visible="0" foreground="0" name="" x="0" y="0" htiled="-1" vtiled="-1" hspeed="0" vspeed="0" stretch="0"/>
<background visible="0" foreground="0" name="" x="0" y="0" htiled="-1" vtiled="-1" hspeed="0" vspeed="0" stretch="0"/>
<background visible="0" foreground="0" name="" x="0" y="0" htiled="-1" vtiled="-1" hspeed="0" vspeed="0" stretch="0"/>
</backgrounds>
<views>
<view visible="0" objName="" xview="0" yview="0" wview="1024" hview="768" xport="0" yport="0" wport="1024" hport="768" hborder="32" vborder="32" hspeed="-1" vspeed="-1"/>
<view visible="0" objName="" xview="0" yview="0" wview="1024" hview="768" xport="0" yport="0" wport="1024" hport="768" hborder="32" vborder="32" hspeed="-1" vspeed="-1"/>
<view visible="0" objName="" xview="0" yview="0" wview="1024" hview="768" xport="0" yport="0" wport="1024" hport="768" hborder="32" vborder="32" hspeed="-1" vspeed="-1"/>
<view visible="0" objName="" xview="0" yview="0" wview="1024" hview="768" xport="0" yport="0" wport="1024" hport="768" hborder="32" vborder="32" hspeed="-1" vspeed="-1"/>
<view visible="0" objName="" xview="0" yview="0" wview="1024" hview="768" xport="0" yport="0" wport="1024" hport="768" hborder="32" vborder="32" hspeed="-1" vspeed="-1"/>
<view visible="0" objName="" xview="0" yview="0" wview="1024" hview="768" xport="0" yport="0" wport="1024" hport="768" hborder="32" vborder="32" hspeed="-1" vspeed="-1"/>
<view visible="0" objName="" xview="0" yview="0" wview="1024" hview="768" xport="0" yport="0" wport="1024" hport="768" hborder="32" vborder="32" hspeed="-1" vspeed="-1"/>
<view visible="0" objName="" xview="0" yview="0" wview="1024" hview="768" xport="0" yport="0" wport="1024" hport="768" hborder="32" vborder="32" hspeed="-1" vspeed="-1"/>
</views>
<instances>
<instance objName="object0" x="96" y="96" name="inst_EB260597" locked="0" code="// inst code&#xA;" scaleX="1" scaleY="1" colour="4294967295" rotation="0"/>
</instances>
<tiles/>
<PhysicsWorld>0</PhysicsWorld>
<PhysicsWorldTop>0</PhysicsWorldTop>
<PhysicsWorldLeft>0</PhysicsWorldLeft>
<PhysicsWorldRight>1024</PhysicsWorldRight>
<PhysicsWorldBottom>768</PhysicsWorldBottom>
<PhysicsWorldGravityX>0</PhysicsWorldGravityX>
<PhysicsWorldGravityY>10</PhysicsWorldGravityY>
<PhysicsWorldPixToMeters>0.100000001490116</PhysicsWorldPixToMeters>
</room>
 
M

mccordinator

Guest
Yea, that was the only way I could think to potentially do it. But it seems like it has so much room for error.
 
Top