Do you think I could just leave this part blank and it'd be okay? We're just going to replace the whole thing with a header image anyway, right?
You are not logged in.
Hello, I'm making a bot using BotBits and currently mostly everything works fine, however I want to add world saving functionality.
Is it possible to serialize an arbitrary block into a series of bytes?
In order to recreate most blocks, you only need their ID, which is easy enough to get, as it's just a ushort, however some blocks have morphs, ids, text, etc. Is it possible to make an elegant serialize function, or do I have to consider every type of team gates, portals, coin doors, signs, admin text, morphable blocks, world portals, etc and encode them differently in a switch case?
Has anybody else done something like this already, so I don't have to reinvent the wheel?
Once I can serialize a foreground block with custom args, I can serialize a world of Pair<BackgroundID, ForegroundBlock>[w, h] easily, this is the only element missing.
Offline
Unfortunately, a serializeable version of a world is not part of BotBits. This is because the world format used by BotBits is optimized for fast random access, and not file size.
You can get a ForegroundBlock's arguments using "block.GetArgs()", it returns an object array.
You can then serialize the block's Id and the given arguments array in the format of your choice.
To deserialize, you can call "WorldUtils.GetForegroundFromArgs(blockId, args)". These blocks can be set in a World ("var world = new World(width, height); world.Foreground[x, y] = block;") or directly uploaded using "Blocks.Of(bot).Place(x, y, block)".
Background blocks should be easy to serialize as they only require an ID.
I have never thought of programming for reputation and honor. What I have in my heart must come out. That is the reason why I code.
Offline
Off topic: This is why I like to make as much as I can myself, because then I don't have these kind of dependencies or things that simply aren't as pretty/easy as they could be. (I'm not criticizing BotBits itself, so pls no hate messages)
Bit more on topic: (Never used BotBits myself, so excuse me if I got something wrong) Wouldn't it be possible to make the list of blocks in BotBits serializable? As you said, it's not optimised for file size. But be honest here, as long as it's below 1MB nobody will notice the file size so it's really no big problem.
Offline
Bit more on topic: (Never used BotBits myself, so excuse me if I got something wrong) Wouldn't it be possible to make the list of blocks in BotBits serializable? As you said, it's not optimised for file size. But be honest here, as long as it's below 1MB nobody will notice the file size so it's really no big problem.
The file size would actually be very close, if not over 1MB for a 400x200 world. Making blocks serializable is something I still need to add to BotBits. Complete worlds however are unlikely to be made serializable. (It isn't hard to move the blocks into a 2D array and serialize them that way though, if you really want a quick serialization...)
Off topic: This is why I like to make as much as I can myself, because then I don't have these kind of dependencies or things that simply aren't as pretty/easy as they could be. (I'm not criticizing BotBits itself, so pls no hate messages)
You have a point. You wouldn't want to wait until a missing feature is added into the framework you use because that takes some time.
As a library designer you help minimize the effects of this issue by making your framework as flexible as possible. In this case it's the fact that BotBits allowed users to access the "GetArgs" and "GetForegroundFromArgs" internal functions, which allows you to serialize blocks by creating simple wrapper classes. BotBits is also open source and serveral people have added things that were missing in the framework themselves.
When you use a library you want to save time by skipping things that were already done by other people and I think BotBits does a good job of that.
I have never thought of programming for reputation and honor. What I have in my heart must come out. That is the reason why I code.
Offline
den3107 wrote:Off topic: This is why I like to make as much as I can myself, because then I don't have these kind of dependencies or things that simply aren't as pretty/easy as they could be. (I'm not criticizing BotBits itself, so pls no hate messages)
You have a point. You wouldn't want to wait until a missing feature is added into the framework you use because that takes some time.
As a library designer you help minimize the effects of this issue by making your framework as flexible as possible. In this case it's the fact that BotBits allowed users to access the "GetArgs" and "GetForegroundFromArgs" internal functions, which allows you to serialize blocks by creating simple wrapper classes. BotBits is also open source and serveral people have added things that were missing in the framework themselves.
When you use a library you want to save time by skipping things that were already done by other people and I think BotBits does a good job of that.
I do agree. Libs are very useful and can make difficult or long tasks become a piece of cake (or close to).
However for things like EE, where I'm not bound to time or code quality I prefer to make most stuff myself.
I must admit though that when a person like you (Processor) would look at my code you'd probably puke, since I haven't been taught yet how to decently do multi-threading on my study (At least I assume I'm doing it the wrong way).
Offline
[ Started around 1732421075.222 - Generated in 0.046 seconds, 12 queries executed - Memory usage: 1.43 MiB (Peak: 1.54 MiB) ]