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.
How do I check the number of empty blocks (Block ID 0) in my world at a certain interval without having to call /loadlevel everytime?
Offline
Do you have a world-deserializer?
You can use that.
shh i have returned
Offline
Start off by deserializing your worlddata in the Init message (obviously).
Then for every "b" event, check if it deleted an 'empty' block or placed one.
Keep track of the amount of 'empty' blocks through an int you constantly add or substract one from.
You can use a Timer to read the variable every now and then.
Offline
isn't world data only received when you join the world and when the world is reset via /loadlevel?
Offline
Start off by deserializing your worlddata in the Init message (obviously).
Then for every "b" event, check if it deleted an 'empty' block or placed one.
Keep track of the amount of 'empty' blocks through an int you constantly add or substract one from.
You can use a Timer to read the variable every now and then.
oh right. I guess I could try that
Offline
loadlevel has it's own event
case "reset":
shh i have returned
Offline
loadlevel has it's own event
case "reset":
Yeah, but the problem is that I don't want to /loadlevel every time I wanna check the empty block count. hm
Offline
den3107 wrote:Start off by deserializing your worlddata in the Init message (obviously).
Then for every "b" event, check if it deleted an 'empty' block or placed one.
Keep track of the amount of 'empty' blocks through an int you constantly add or substract one from.
You can use a Timer to read the variable every now and then.oh right. I guess I could try that
*FOLLOW UP QUESTION* How do I check if a player just simply replaced a block? Because in this case, I wouldn't want to subtract to the empty block count.
Offline
madiik wrote:loadlevel has it's own event
case "reset":Yeah, but the problem is that I don't want to /loadlevel every time I wanna check the empty block count. hm
Then you should need to keep track of them an empty block is deleted or placed.
Harder to code but a bit more friendly and faster too.
Offline
You don't need to loadlevel every time.
Modify the roomdata whenever a block is placed.
Owner blocks have their own message types, too, so you might wanna check whenever they're placed on their cases.
Unless you don't need them.
kurtv13 wrote:▼Hidden text*FOLLOW UP QUESTION* How do I check if a player just simply replaced a block? Because in this case, I wouldn't want to subtract to the empty block count.
case "b":
int layer = e.GetInt(0), x = e.GetInt(1), y = e.GetInt(2), bid = e.GetInt(3); // Set the variables you get from the message.
if (bid != 0 && roomData[layer, x, y].BlockID == 0) // Check if the block that was previously there was an empty one, and if the new one isn't 0.
emptyBlocks--; // Decrease the amount of empty blocks by one.
roomData[layer, x, y].BlockID = bid; // Set the new block at the given coords to the given block id to keep your room data updated.
break;
Offline
You don't need to loadlevel every time.
Modify the roomdata whenever a block is placed.
Owner blocks have their own message types, too, so you might wanna check whenever they're placed on their cases.
Unless you don't need them.kurtv13 wrote:kurtv13 wrote:▼Hidden text*FOLLOW UP QUESTION* How do I check if a player just simply replaced a block? Because in this case, I wouldn't want to subtract to the empty block count.
case "b": int layer = e.GetInt(0), x = e.GetInt(1), y = e.GetInt(2), bid = e.GetInt(3); // Set the variables you get from the message. if (bid != 0 && roomData[layer, x, y].BlockID == 0) // Check if the block that was previously there was an empty one, and if the new one isn't 0. emptyBlocks--; // Decrease the amount of empty blocks by one. roomData[layer, x, y].BlockID = bid; // Set the new block at the given coords to the given block id to keep your room data updated. break;
This should do the trick. Many thanks!
Offline
[ Started around 1732216074.8338 - Generated in 0.247 seconds, 10 queries executed - Memory usage: 1.53 MiB (Peak: 1.7 MiB) ]