Saving Changes to the Map
Displaying 1-7 of 7 total.
1
Please enter a numerical value for the importance of this sticky.
Enter 0 to unsticky.
Goldengamer111

I have been using a 16x16 pixel tilesize for my game but realized that most of those tiles were made out of 8x8 tiles, so I am currently resizing everything to twice the original size (I was doing that with SetResolution() anyway) to allow for more detail. However, some of the tiles are not able to be used in the new size without complicated tiling, and I thought that it might be nice to have a placeholder tile to put in the map, and then run that through a program that replaced it with what it should be using something like the code below.
for(h=0;h<=curmap.h;h++){
for(w=0;w<=curmap.w;w++){
if (GetTile(h,w)==6) SetTile(h,w,Random(7,8);
}
for(w=0;w<=curmap.w;w+=2){
if (GetTile(h,w)==9) SetTile(h,w,10);
}
for(w=1;w<=curmap.w;w+=2){
if (GetTile(h,w)==9) SetTile(h,w,11);
}
}

Unfortunately, there doesn't seem to be any way to save these changes to the map. Am I missing something, or am I stuck with redoing the change every time the map loads?

Posted on 2009-12-13 16:53:44

Kildorf

Actually, there's a relatively new function that will save your current map:

FileWriteMap() -- http://verge-rpg.com/docs/view.php?libid=1&function=415

You can use curmap.path to get the current map's on-disk location, too, if you want to do this processing and save it over the old one (though it sounds like you might(?) want to just save them in a "processed" directory or something? I dunno.)

Good luck!

Posted on 2009-12-19 07:28:16

Goldengamer111

Thanks for that, it looks like it will be great! I only have one more question about this: How does FileWriteMap() work? The doc page isn't very descriptive...

Posted on 2009-12-21 23:27:38

Overkill

Really? I mean, there's not that much to it.

Well, it's intentionally vague to discourage users from writing maps unless they absolutely have to, because the flexibility over map modifications after the map is loaded isn't entirely there engine-side.

I mean, Verge provides a lot of the functionality to the user, but some things like layer creation/removal, entity removal, zone creation/removal, can't really be done at runtime. If you're fine with only being able to really save the results of SetTile on an existing map, you'll probably be fine.



Anyways, as it describes in the manual, it simply writes the active map into the file handle you specify. If you understand how file writing works in Verge, then this shouldn't be bad.

Just open a file, write the map, close the file.

Any (or most, anyway) of the changes you did to the map will be saved when you write the map to a file.

You can get the path of the current file from curmap.path to modify the map in-place, but this is probably not recommended for what you're doing. Or you could just open a completely different file, which is more recommended.

Also, errr, after you save a map, it has no scripts loaded in yet (I think), so if you intend to save and then switch back to that map later, without closing the engine, try using CompileMap(string filename); afterwards.


Okay, this should be more than sufficient information to use it now. Good luck!

Posted on 2009-12-23 02:19:32

Overkill

(This second post was sort of a mistake. Misread the point of the needing something to process the maps)

Posted on 2009-12-23 02:25:18 (last edited on 2009-12-23 02:38:09)

Goldengamer111

Thanks! I'm not sure how I missed the meaning, but the vagueness seems to have served its purpose, and this seems to be the perfect function for what I'm trying to do.

Posted on 2009-12-23 18:32:48

Goldengamer111

EDIT: Moved to a new thread.

Posted on 2009-12-29 14:30:02 (last edited on 2010-01-24 19:35:26)


Displaying 1-7 of 7 total.
1
 
Newest messages

Ben McGraw's lovingly crafted this website from scratch for years.
It's a lot prettier this go around because of Jon Wofford.
Verge-rpg.com is a member of the lunarnet irc network, and would like to take this opportunity to remind you that regardless how babies taste, it is wrong to eat them.