English [Script] Custom map editor saving

8 replies
Goto Page
To the start Previous 1 Next To the start
Up
_oops
User
Offline Off
Hello, I made a script that players able to do map editing in the game by using @cs2d cmd settile command.

IMG:https://i.imgur.com/6WY86jd.png


But I know that this is meaningless if script can not save edited data.

I searched for similar scripts - file cs2d 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 cs2d lua cmd tile command to get frames with loop ( start with 0 to cs2d lua cmd map("xsize"), 0 to cs2d lua cmd 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?
30.10.19 08:29:59 am
Up
Gaios
Reviewer
Offline Off
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
30.10.19 03:57:09 pm
Up
Jarates
User
Offline Off
@user 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
30.10.19 07:20:03 pm
Up
DC
Admin
Offline Off
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
www.UnrealSoftware.de | www.CS2D.com | www.CarnageContest.com | Use the forum & avoid PMs!
31.10.19 12:23:25 am
Up
_oops
User
Offline Off
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
31.10.19 12:34:17 am
Up
VADemon
User
Offline Off
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.
31.10.19 01:12:17 am
Up
_oops
User
Offline Off
Thanks! I will post again if I stuck
31.10.19 10:47:25 am
Up
DC
Admin
Offline Off
Yes, what user VADemon said. It's also mentioned in the file:
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-)


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.
www.UnrealSoftware.de | www.CS2D.com | www.CarnageContest.com | Use the forum & avoid PMs!
04.11.19 09:32:31 am
Up
Gaios
Reviewer
Offline Off
Will you keep entities cs2d lua cmd entitylist and blending cs2d lua cmd tile?
To the start Previous 1 Next To the start