Independant function calls?
#1
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:

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.
Reply
Thanks given by:


Messages In This Thread
Independant function calls? - by DiamondToaster - 01-17-2015, 12:59 PM
RE: Independant function calls? - by xoft - 01-17-2015, 05:23 PM
RE: Independant function calls? - by xoft - 01-17-2015, 05:27 PM
RE: Independant function calls? - by sphinxc0re - 01-17-2015, 10:07 PM
RE: Independant function calls? - by xoft - 01-17-2015, 11:08 PM
RE: Independant function calls? - by Seadragon91 - 01-17-2015, 11:57 PM
RE: Independant function calls? - by xoft - 01-18-2015, 03:51 AM
RE: Independant function calls? - by tonibm19 - 01-18-2015, 04:27 AM
RE: Independant function calls? - by tigerw - 01-18-2015, 09:09 AM



Users browsing this thread: 1 Guest(s)