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.
Pages: 1
Basically:
Like in ShiftBot, how to isolate blocks buildings from the commands, so once you build a map, you can still use commands.
Use multiple threads and locks
I usually have a Queue<object[]> where object is the b messages being sent, and Place and BlockPlaceTick functions using locks to add and remove blocks from the queue
BlockPlaceTick is usually then called by a timer, and has a while(curTick < curTime) so it can place blocks faster than the max timer speed
Edit: Locks basically make it so two threads wait for each other to finish using data before they try to access it, as if they both used it at the same time, bad things could happen
Offline
Or, if you're not worried about potential thread issues,
new Thread(() =>
{
//send blocks
}).Start();
One bot to rule them all, one bot to find them. One bot to bring them all... and with this cliché blind them.
Offline
What is more suggested? That Queue stuff or Threads?
What is more suggested? That Queue stuff or Threads?
Depends what youre using it for, some things wouldnt cause any threading problems, so you could just use Tomahawks, but other things might need the locks and queues to prevent errors
Offline
Screams Async in the background
Thanks to: Ernesdo (Current Avatar), Zoey2070 (Signature)
Very inactive, maybe in the future, idk.
Offline
I personally have my main thread (duh), a thread for my message handler (so I don't have to worry about delays in messages) and a thread for my block handler. All I then just do is call a function and the block handler will do the rest.
Offline
Screams Async in the background
It really depends what youre using it for, if it was a shift like world, you should probably use async as youd want to have a callback once it had finished placing, and wouldnt need mutliple things being placed at once, but if it was something where, for example commands could place structures, that wouldnt work very well, as you could have multiple placement loops at the same time, which would lead to an inconsistant placement speed, plus iirc async is for things that would need a callback, which it wouldnt
Offline
you should probably use async as youd want to have a callback once it had finished placing
I personally provide an optional "onComplete" Action parameter to my block handler. Just push in a method or an () => { anonymous.Method(); } and you got your callback.
Offline
destroyer123 wrote:you should probably use async as youd want to have a callback once it had finished placing
I personally provide an optional "onComplete" Action parameter to my block handler. Just push in a method or an () => { anonymous.Method(); } and you got your callback.
You definately can do it that way, but IMO its neater to use async / await, as then all your code is all at one 'level', and is run from top to bottom
Offline
Pages: 1
[ Started around 1732694369.6135 - Generated in 0.231 seconds, 12 queries executed - Memory usage: 1.51 MiB (Peak: 1.66 MiB) ]