Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --MrRepside programm enjoy
- local storageName = "minecraft:barrel_3"
- local jukeBoxeName = "minecraft:jukebox_0"
- local routerName = "modularrouter:item_router_0"
- local chatboxName = "chatBox_4"
- local storage = peripheral.wrap(storageName)
- local chatbox = peripheral.wrap(chatboxName)
- function GetMusicMessage()
- local event, username, message = os.pullEvent("chat")
- local find, numberFind = string.find(message, "DJ play")
- if find == 1 and numberFind == 7 then
- return 1, string.sub(message, 9)
- else
- find, numberFind = string.find(message, "DJ stop")
- if find == 1 and numberFind == 7 then
- return 2, nil
- end
- end
- end
- function FindMusicPlace(musicName)
- local list = storage.list()
- for i=1,#list do
- if string.find(list[i].name, musicName) then
- print("trouvé le cd ici", list[i].name, i)
- return i
- end
- end
- return nil
- end
- function PlayMusic(place, name)
- storage.pushItems(routerName, place, 1)
- chatbox.sendMessage("Hey I'm playing "..name)
- end
- function StopMusic()
- storage.pullItems(jukeBoxeName, 1)
- end
- while true do
- local mode, musicName = GetMusicMessage()
- if mode == 1 then --joue
- local musicslot = FindMusicPlace(musicName)
- if musicName == nil or musicslot == nil then
- chatbox.sendMessage("Didn't found the disc :(")
- else
- StopMusic()
- PlayMusic(musicslot, musicName)
- end
- elseif mode == 2 then --Stop
- StopMusic()
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement