Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local event = require("event")
- local component = require("component")
- local chat = component.chat_box
- local cb = component.command_block
- local unicode = require "unicode"
- local disableWhitelist = false
- local function runCommand(command, ...)
- local command = "/" .. command .. " " .. table.concat({...}, " ")
- --print(command)
- cb.setCommand(command or defaultCommand)
- cb.executeCommand()
- end
- local function findKeywords(str, tbl)
- local keywordsCount = {}
- for k, v in pairs(tbl) do
- string.gsub(unicode.lower(str), k, function(k)
- if ( not keywordsCount[k] ) then keywordsCount[k] = 0 end
- keywordsCount[k] = keywordsCount[k] + 1
- end)
- --print(k, '=', keywordsCount[k])
- end
- return keywordsCount
- end
- local sounds = {
- ["мяу"] = "mob.cat.meow",
- ["meow"] = "mob.cat.meow",
- ["мяя"] = "mob.cat.meow",
- ["мур"] = "mob.cat.purreow",
- ["гав"] = "mob.wolf.bark",
- ["bark"] = "mob.wolf.bark",
- ["hiss"] = "mob.cat.hiss",
- ["creeper"] = "mob.creeper.say",
- ["fuse"] = "random.fuse",
- ["хрю"] = "mob.pig.say"
- }
- local whitelist = {
- ["paladincvm"] = true,
- ["pirnogion"] = true,
- ["pornogion"] = true,
- ["tamik_77"] = true,
- ["Tinrion"] = true,
- }
- print("Copyright 2016 (C) Pirnogion - Посвящается Пиру и Палу")
- while true do
- local e = {event.pull()}
- if (e[1] == "chat_message") then
- --local sound = sounds[ unicode.lower(e[4]) ]
- local access = disableWhitelist or whitelist[ unicode.lower(e[3]) ]
- --print("Debug: ", sound, access)
- local keywordsCount = findKeywords(e[4], sounds)
- if ( access ) then
- for k, v in pairs(sounds) do
- if ( keywordsCount[k] ) then
- chat.say(e[3] .. " сказал " .. keywordsCount[k] .. " раз " .. k)
- for i=1, keywordsCount[k], 1 do
- runCommand("playsound", v, "@a")
- os.sleep(0.2)
- end
- end
- end
- end
- end
- end
Add Comment
Please, Sign In to add comment