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.
Insprired by stilltoolazytomakeanacc's post:
Let's just keep making more deserializers.
[...]
The real winner is to make one that doesn't break down when new specials are made.
So I decided to take up the challenge and created... InitParse!
InitParse dynamically detects special blocks and their parameters (and it does not have any special block ids hardcoded). Therefore, it will not break when new blocks are introduced in the game.
It has been optimized for performance and parsing "init" messages of semi-full 200x200 worlds took ~475µs (about 1/2000th second) on average.
How to use:
Visit the github page and copy paste the file contents of InitParse.cs into your own project.
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
Sounds pretty cool.
Offline
There's a problem here:
if (m.Type != "init" && e.Type != "reset")
e does not exist in current context. It should be m.
shh i have returned
Offline
There's a problem here:
if (m.Type != "init" && e.Type != "reset")
e does not exist in current context. It should be m.
It's whatever you name your PlayerIoClient.Message, you can name it banana, everyone just uses 'm' for 'message'
If you would like me to make a bot for you, go here.
Offline
Insprired by stilltoolazytomakeanacc's post:
stilltoolazytomakeanacc wrote:Let's just keep making more deserializers.
[...]
The real winner is to make one that doesn't break down when new specials are made.So I decided to take up the challenge and created... InitParse!
InitParse dynamically detects special blocks and their parameters (and it does not have any special block ids hardcoded). Therefore, it will not break when new blocks are introduced in the game.
It has been optimized for performance and parsing "init" messages of semi-full 200x200 worlds took ~475µs (about 1/2000th second) on average.How to use:
Visit the github page and copy paste the file contents of InitParse.cs into your own project.
Sorry if I sound ignorant, but how do I pass the roomData variable (uint[*.*.*]) to a variable that I can use from m.Type == "say"?
This is of course from the example. I am new to world deserializers. Anyway, since I need to verify a block in the m.Type == "say" message, I'd kinda like to know how to have this variable declared at the start. I can't seem to be able to create such a uint variable.
Offline
madiik wrote:There's a problem here:
if (m.Type != "init" && e.Type != "reset")
e does not exist in current context. It should be m.
It's whatever you name your PlayerIoClient.Message, you can name it banana, everyone just uses 'm' for 'message'
If he made his Message parameter to "m", it should be "m" not "e"
shh i have returned
Offline
My bad -_- Has been fixed, thanks madiik for pointing it out.
---
Psychocrysma: First create a variable outside your function:
static uint[,,] world;
Then set it in your code, so you have something like this:
static uint[,,] world;
static void Connection_OnMessage(object sender, Message e)
{
switch (e.Type)
{
case "init":
var roomData = new uint[2, e.GetInt(12), e.GetInt(13)];
var chunks = InitParse.Parse(e);
foreach (var chunk in chunks)
foreach (var pos in chunk.Locations)
roomData[chunk.Layer, pos.X, pos.Y] = chunk.Type;
// Set the world
world = roomData;
break;
case "say":
if (world[0, 0, 0] == 44) { // If top left corner is fully black...
// TODO: Do something here
}
break;
}
}
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
My bad -_- Has been fixed, thanks madiik for pointing it out.
---
Psychocrysma: First create a variable outside your function:
static uint[,,] world;
Then set it in your code, so you have something like this:
static uint[,,] world; static void Connection_OnMessage(object sender, Message e) { switch (e.Type) { case "init": var roomData = new uint[1, e.GetInt(12) - 1, e.GetInt(13) - 1]; var chunks = InitParse.Parse(e); foreach (var chunk in chunks) foreach (var pos in chunk.Locations) roomData[chunk.Layer, pos.X, pos.Y] = chunk.Type; // Set the world world = roomData; break; case "say": if (world[0, 0, 0] == 44) { // If top left corner is fully black... // TODO: Do something here } break; } }
EDIT: He fixed it. Thanks~
Offline
He fixed it. Re-copy the source. Note how his previous version has "static uint[] world;" instead of "static uint[,,] world;"
shh i have returned
Offline
So, I got this error:
Translation: Index is out of the limits of the table. Well, it's too big.
EDIT: My world is the biggest size you can have in the shop. Dunno how it was called~
I also get this error that makes me think that there's probably something very wrong in there:
Offline
I can't even seem to assign the "world" variable, BUT I NEED IT. It's just like...
var roomData = new uint[1, m.GetInt(12) - 1, m.GetInt(13) - 1];
var chunks = InitParse.Parse(m);
foreach (var chunk in chunks)
foreach (var pos in chunk.Locations)
roomData[chunk.Layer, pos.X, pos.Y] = chunk.Type;
// oh let's stop here and not let madiik assign this variable :) :) :) :)
world = roomData;
shh i have returned
Offline
Oh come on people, learn to debug. Everyone makes off-by-one errors
I've fixed the error in examples.
Must be
var roomData = new uint[2, e.GetInt(12), e.GetInt(13)];
instead of
var roomData = new uint[1, e.GetInt(12) - 1, e.GetInt(13) - 1];
Note to self: Next time, make sure to debug your code before posting it here...
EDIT:
I can't even seem to assign the "world" variable, BUT I NEED IT. It's just like...
var roomData = new uint[1, m.GetInt(12) - 1, m.GetInt(13) - 1]; var chunks = InitParse.Parse(m); foreach (var chunk in chunks) foreach (var pos in chunk.Locations) roomData[chunk.Layer, pos.X, pos.Y] = chunk.Type; // oh let's stop here and not let madiik assign this variable :) :) :) :) world = roomData;
Yeah that's because its crashing before it can set the variable, try the fix I posted above.
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
Then again... Your github readme says "0, m.GetInt(12), m.GetInt(13)"
Are we sure that even Processor knows how to handle this?
I don't see how this "chunk" system works.
MOAR EDIT:
I don't believe you know how your own deserializer works. Tried the fix above
shh i have returned
Offline
Oh come on people, learn to debug. Everyone makes off-by-one errors
I've fixed the error in examples.
Must be
var roomData = new uint[2, e.GetInt(12), e.GetInt(13)];
instead of
var roomData = new uint[1, e.GetInt(12) - 1, e.GetInt(13) - 1];
Note to self: Next time, make sure to debug your code before posting it here...
EDIT:
madiik wrote:I can't even seem to assign the "world" variable, BUT I NEED IT. It's just like...
var roomData = new uint[1, m.GetInt(12) - 1, m.GetInt(13) - 1]; var chunks = InitParse.Parse(m); foreach (var chunk in chunks) foreach (var pos in chunk.Locations) roomData[chunk.Layer, pos.X, pos.Y] = chunk.Type; // oh let's stop here and not let madiik assign this variable :) :) :) :) world = roomData;
Yeah that's because its crashing before it can set the variable, try the fix I posted above.
Well, still not working for me. I'm not sure what's wrong. Your code is way too advanced for me (in the class, I mean). Well, I'm going to guess that there is still a lot to be done on this. I have the same problem as madiik BTW
Offline
Console: No Errors.
Output: No Errors.
ME: Cool , let's try.
*some minutes later*
ME: FFFFFFFUUUUUUUUUUUU. CODE RUIINED. FFFFFUUUUUUUUUUUUU!
No seriously, index was outside of array? oh mah gosh...
Variables.blockIDs = new uint[2, m.GetInt(12), m.GetInt(13)];
var chunks = InitParse.Parse(m);
foreach (var chunk in chunks)
{
foreach (var pos in chunk.Locations)
{
Variables.blockIDs[chunk.Layer, pos.X, pos.Y] = chunk.Type;
}
}
Variables.blockIDs is same as roomData. EXACTLY EQUAL (except not a var and yes an uint[,,]).
It's supposed to work, but even with normal roomData it did the same.
Offline
Processor wrote:Oh come on people, learn to debug. Everyone makes off-by-one errors
I've fixed the error in examples.
Must be
var roomData = new uint[2, e.GetInt(12), e.GetInt(13)];
instead of
var roomData = new uint[1, e.GetInt(12) - 1, e.GetInt(13) - 1];
Note to self: Next time, make sure to debug your code before posting it here...
EDIT:
madiik wrote:I can't even seem to assign the "world" variable, BUT I NEED IT. It's just like...
var roomData = new uint[1, m.GetInt(12) - 1, m.GetInt(13) - 1]; var chunks = InitParse.Parse(m); foreach (var chunk in chunks) foreach (var pos in chunk.Locations) roomData[chunk.Layer, pos.X, pos.Y] = chunk.Type; // oh let's stop here and not let madiik assign this variable :) :) :) :) world = roomData;
Yeah that's because its crashing before it can set the variable, try the fix I posted above.
Well, still not working for me. I'm not sure what's wrong. Your code is way too advanced for me (in the class, I mean). Well, I'm going to guess that there is still a lot to be done on this. I have the same problem as madiik BTW
+1
Offline
I want answers Processor qq
I'M DIEING TO MAKE SOMETHING FUN D:
does not liek this.
shh i have returned
Offline
I still didn't test it even once. Q_Q
Okay so, my bad, I got owned by operator precedence. Use the newer version of the gist, I promise it works now (because I actually tested it once!!)
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
I still didn't test it even once. Q_Q
Okay so, my bad, I got owned by operator precedence. Use the newer version of the gist, I promise it works now (because I actually tested it once!!)
Works fine for me!!! Thanks~
Offline
"A world deserializer that never breaks!"
> Breaks 4 times before it's fixed.
Dammit processor.
Offline
lol processor is too good to test, no time for that
Very nice tho
If you would like me to make a bot for you, go here.
Offline
Argh, I'm probably misguided but seeing quantum physics stuff this like just for a Flash game makes me give up all my hope of actually learning programming someday.
Offline
lol processor is too good to test, no time for that
Very nice tho
And agreed, nice work
[Edit] Just tried it. Awesome, works well.
Offline
I still didn't test it even once. Q_Q
Okay so, my bad, I got owned by operator precedence. Use the newer version of the gist, I promise it works now (because I actually tested it once!!)
It's fixed now.
Also processor,
'The (best)','Therefore, it will not break when new blocks are introduced in the game.'
>= Breaks 4 times
kkkkk i beliv u omg give me siganutre
(no srs, breaks 4 times before works at once)
Offline
'The (best)','Therefore, it will not break when new blocks are introduced in the game.'
>= Breaks 4 times
kkkkk i beliv u omg give me siganutre
(no srs, breaks 4 times before works at once)
plsgo someone already made this joke
thx for sig bobithan
Offline
[ Started around 1732216116.2462 - Generated in 0.429 seconds, 10 queries executed - Memory usage: 1.87 MiB (Peak: 2.17 MiB) ]