Loffen
Well-known member
I am actually coding a map-loader class for my game. In the beginning the map format was quite simple, and i could just read line after line and put things together. Now, my mapformat is getting more complicated, and its much easier to make the whole thing crash. I have done some PHP and i know what regular expressions are, but i never bothered to learn them (mostly because i never needed them), but i think thats the thing i have to use..
My maps are separated into four sections. Config, Terrain data, Object data and Trigger data. I want to read the whole file, then split it up using reg expr. To clearify this ill make an example:
The map:
Here id like to separate the config, terrain data etc, like this:
ConfigVar =
TerrainDataVar =
etc...
I really have no ideas how to do this. If you know some good tutorials, please post them here. Suggestions?? I dont care if i have to change the map format a little...
-- Loffen
My maps are separated into four sections. Config, Terrain data, Object data and Trigger data. I want to read the whole file, then split it up using reg expr. To clearify this ill make an example:
The map:
Code:
[MAP_CONFIG:
map_name=Testmap
map_tileset=Default
]
[MAP_TERRAIN_DATA:
0;1;0;1;0;1;0;1;
0;1;0;1;0;1;0;1;
0;1;0;1;0;1;0;1;
0;1;0;1;0;1;0;1;
]
[MAP_OBJECT_DATA:
tree{pos=2,2;}
tree{pos=6,3;}
]
[MAP_TRIGGER_DATA:
hurt{pos=0,0;dmgamount=10;}
]
Here id like to separate the config, terrain data etc, like this:
ConfigVar =
Code:
map_name=Testmap
map_tileset=Default
TerrainDataVar =
Code:
0;1;0;1;0;1;0;1;
0;1;0;1;0;1;0;1;
0;1;0;1;0;1;0;1;
0;1;0;1;0;1;0;1;
etc...
I really have no ideas how to do this. If you know some good tutorials, please post them here. Suggestions?? I dont care if i have to change the map format a little...
-- Loffen
Last edited by a moderator: