I got busy and started to write an MCSmash plugin (Super Smash Bros. im Minecraft), but I came across a bit of a wall. Lets say I got a sleep function:
I want to do a little noteblock music on command, but when I do this:
The entire server freezes while that function runs. Coroutines don't seem to help much here either. Any way I could get around this?
Also, the "F5" and stuff are just numerical constants.
1 2 3 4 | function sleep(n) -- seconds local t0 = clock() while clock() - t0 <= n do end end |
I want to do a little noteblock music on command, but when I do this:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | function PlayNoteBlock() NoteEntity:SetPitch(F5) NoteEntity:MakeSound() sleep(0.2) NoteEntity:MakeSound() sleep(0.2) NoteEntity:MakeSound() sleep(0.2) NoteEntity:SetPitch(D5) NoteEntity:MakeSound() sleep(0.1) NoteEntity:SetPitch(F5) NoteEntity:MakeSound() sleep(0.2) NoteEntity:MakeSound() sleep(0.2) NoteEntity:SetPitch(D5) NoteEntity:MakeSound() sleep(0.1) NoteEntity:SetPitch(F5) NoteEntity:MakeSound() sleep(0.1) NoteEntity:SetPitch(D5) NoteEntity:MakeSound() sleep(0.1) NoteEntity:SetPitch(F5) NoteEntity:MakeSound() sleep(0.2) end |
The entire server freezes while that function runs. Coroutines don't seem to help much here either. Any way I could get around this?
Also, the "F5" and stuff are just numerical constants.