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.
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:
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.