[Script] Custom map editor saving
8 replies



30.10.19 07:04:59 am
Hello, I made a script that players able to do map editing in the game by using @
settile command.

But I know that this is meaningless if script can not save edited data.
I searched for similar scripts -
MikuAuahDark: Map Protection v1.0 (10) ,and someone uploaded old C4 server script previously but seems like it has been deleted ( here, this is file )
also I read about map format spec text file however, I couldn't find clear way to make new individual cs2d map file.
The way how I am thinking about make new individual map file is -
1. use
tile command to get frames with loop ( start with 0 to
map("xsize"), 0 to
map("ysize") )
2. Convert em into hexadecimal value
3. Save it as new map_name.map file
so.. question is
How can I write a map that currently running in server as new map file via lua?
Writing header ( Unreal Software's CS2D Map File (max) ), tiles and stuffs. any example or tips?


But I know that this is meaningless if script can not save edited data.
I searched for similar scripts -


also I read about map format spec text file however, I couldn't find clear way to make new individual cs2d map file.
The way how I am thinking about make new individual map file is -
1. use



2. Convert em into hexadecimal value
3. Save it as new map_name.map file
so.. question is
How can I write a map that currently running in server as new map file via lua?
Writing header ( Unreal Software's CS2D Map File (max) ), tiles and stuffs. any example or tips?
I have written a map format in PHP and C#, same would go with Lua. You can contact me at discord Gaios#9324 so we can finish the project
. Be aware that the Lua script that you have found may be outdated.

edited 1×, last 30.10.19 10:18:13 am
@
Gaios: you didn’t finish your own projects metin2d, minecraft etc. And you want to finish this guys project. You done enough gaios, let others finish what you started

The map format is documented here:
http://www.unrealsoftware.de/files_pub/cs2d_spec_map_format.txt
In theory you can use Lua's IO methods to write all required data to a file. If you strictly follow the format documentation you will then be able to load the map in CS2D.
Also see https://www.lua.org/pil/21.2.2.html
http://www.unrealsoftware.de/files_pub/cs2d_spec_map_format.txt
In theory you can use Lua's IO methods to write all required data to a file. If you strictly follow the format documentation you will then be able to load the map in CS2D.
Also see https://www.lua.org/pil/21.2.2.html
Eeee, I want save the map with lua, so about the before convert data into binary, I need to write basic header as string value ( Unreal Software's CS2D Map File (max) ) and.. What about unused string, integer values? Do I just add empty string value for fill the place of unused parts?
Little example would be thankful
Little example would be thankful
Yes, correct. You just write out values as-is and numbers in their proper binary format.
If there's something unused, it's probably best to write 0x00 - I think this is what CS2D does. You'll also need to work a lot inside a hex editor to make sure everything's alright.
If there's something unused, it's probably best to write 0x00 - I think this is what CS2D does. You'll also need to work a lot inside a hex editor to make sure everything's alright.
Yes, what
VADemon said. It's also mentioned in the file:
It actually doesn't matter which value you write for the -unused- fields because they are not used at all. But they may be used in future so writing 0 / empty string makes it future proof.

Quote:
BYTE/SHORT/INT defaults to the value 0 (use default when -unused-)
STRING defaults to an empty string with linebreak (use default when -unused-)
STRING defaults to an empty string with linebreak (use default when -unused-)
It actually doesn't matter which value you write for the -unused- fields because they are not used at all. But they may be used in future so writing 0 / empty string makes it future proof.



