To make your own file type, just use file I/O. Ideally you'd make a spec for the file type and then implement a loader and saver for the spec, but you don't have to work that way. Here's a simple map data format:
["key=value" metadata rows, strip spaces]
## BEGIN MAP ##
[csv tile id rows]
CSV is shorthand for comma-separated value.
An example of this would be :
map_name=murdertown
tileset='blood_village.ts'
## BEGIN MAP ##
10,10,10,10,10
1,2,3,4,5,6,7,8
10,10,10,10,10
1,1,1,1,1,1,1,1
It's not what I'd call a good format, but it has the advantage of being very very easy to implement. All of the parsing can be done using knowledge from a one-semester intro to programming or a basic programming tutorial. Here's how:
1. To get the key/value pairs split lines on "=" and store in an appropriate data structure. If you know how to use a hash or dict, use that. Otherwise, either learn how or make an associative array of some sort. If you take my advice to strip spaces, do that before storing. If you think you can handle stripping spaces everywhere but inside quotes, do that instead.
2. Do the above until you reach a line that matches "## BEGIN MAP ##". You could use a nicer separator if you want, but this one has the advantage of being hard to fuck up.
3. Keep going, reading the lines, split by commas, into a 2D array. If you use an array and not a list, you'll have to do an initial pass to determine the max width and max height of the array.
4. Hooray you did it.
5. Writing is the reverse process of the above.
It's not the best format, but I'm pretty sure it's one of the easier ones.
Thanks, I can probably work out the editor on my own but I only have a minor idea on creating my own file type, Would if be possible to use a resource file to store multiple things together as one file? the idea i had for my map files would store multiple things, such as 3 layers (back, middle and for) a layer for event nodes and so on. I had the idea to store it all in one file but as seprate parts, like a small data archive with seprate files for each layer, then after each file is loaded into memmory I can access each part of the file as a funtion like:
icecave.layer[1];
icecave.node[ID023123](blah blah blah);
I'm still documenting it but i'll get to writting a file spec later, need to go out right now.
Also what's this about? there's a lot I still don't know about when it comes to programming
["key=value" metadata rows, strip spaces]
I was thinking of using somthing like this as a file structure:
.map archive file structure
-Map layer files X3 (text file)
-[CSV tile ID]
-Map Refrences file (XML)
-MapName(MAPID)
-MapType
-FX
-MapAmbience:
-MapBGM
-MapScreenEffect
-Tileset
-Nodes on map file (XML)
-NodeName(NodeID)
-NodeType
-NodeXY(x,y)
-Nodelink(from,to)
-Node relation ship file (XML)
-MasternodeID
-NodelinkedToMasterNodeID(conection type)
-NodelinkedToMasterNodeID(Conection type)
My idea is store each part as a seprate file but store all of them in one main file called a .map like an archive i think i could use a resource file for this, then i just access each file when i need it.
the Reason as to why i want to store it sepratelay is becuase i don't know How much of things will be stored, how many nodes, how big the map is, etc, a lot of those will be decided on runtime and generated as is.
The reason I' m storing relationships Is becuase I want to be able to link multiple things together and how they intereact is decided by a node type, that's defined seprately, so if i want i can create a chain of switchtches that need to be filmed or on a certain order and so on. I can do that becuase some of that maps will be generated from pre-made structures (rooms with puzzles) and some are random (with pre made puzzles randomly placed). some of the nodes arn't viable to the player, like gates and such, not, and, or, xor, etc, using those i can create interesting switch puzzles like for example like one that needs to be hit in the right order and so on.