This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
YoYoYonnY's profile picture

[1.57] disk.isPlaying(string side) or os.pullEvent( "disk_stopedPlaying" )

Started by YoYoYonnY, 30 November 2013 - 04:50 AM
YoYoYonnY #1
Posted 30 November 2013 - 05:50 AM
We got disk.playAudio().
We got disk.stopAudio().
So what about disk.isPlaying()?

The Idea
disk.isPlaying() would be useful if you want to loop the audio from a music disk, or if you want to know when the disk ends. In some cases it would be possible to find the length of the disks by using the title and the Minecraft Wiki, but when you're using a mod like iChun's portal gun mod, it becomes difficult, because mods like these will add additional music disks. Also, when using later versions of minecraft (1.7.2+) you can add additional music disks. With unknown lengths.

An Event
Maybe, disk.isPlaying() isn't that a great idea, because it's a function. In that case, maybe it is an idea to add a event that fires the side of the music disk that stopped playing. And there's another possibility. If disk.playAudio() just returns true or false, you can still know if the disk is playing or not. However, in this case your audio will start over from the beginning.

Examples:

while true do
	sEvent, param1, param2, param3 = os.pullEvent()
	if sEvent == "disk_stoppedPlaying" then
		disk.playAudio( param1 )
	end
end

while true do
	if disk.hasAudio( "bottom" ) and not disk.isPlaying( "bottom" ) then
		disk.playAudio( "bottom" )
	end
end

while true do
	for n=1,#rs.getSides() do
		if disk.hasAudio( rs.getSides()[ n ] ) and not disk.isPlaying(rs.getSides()[ n ] ) then
			disk.playAudio( rs.getSides()[ n ] )
		end
	end
end
Lyqyd #2
Posted 30 November 2013 - 12:18 PM
This has been discussed before. Server-side has no particularly effective way of knowing what the client-side is doing as far as playing the music is concerned.
Engineer #3
Posted 30 November 2013 - 12:32 PM
This has been discussed before. Server-side has no particularly effective way of knowing what the client-side is doing as far as playing the music is concerned.
It's called packets, with those you can communicate from the client to the server and vice versa.

However, such a packet just for the music disk is quite pointless tbh.
Lyqyd #4
Posted 30 November 2013 - 01:03 PM
And which client should be taken as the authoritative source for song length? Music can be switched out via resource packs.
Engineer #5
Posted 30 November 2013 - 01:54 PM
And which client should be taken as the authoritative source for song length? Music can be switched out via resource packs.
Touché
jay5476 #6
Posted 01 December 2013 - 01:38 AM
Well maybe do a music event
Return music,side,name,(start or end)

That way people can just time disks by events
Lyqyd #7
Posted 01 December 2013 - 11:19 AM
Did you read any of the rest of the topic?

Locked.