Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function Split(s, delimiter)
- result = {};
- for match in (s..delimiter):gmatch("(.-)"..delimiter) do
- table.insert(result, match);
- end
- return result;
- end
- colorTable = {}
- colorTable['white'] = 25368
- colorTable['blue'] = 16
- colorTable['green'] = 768
- colorTable['red'] = 24576
- colorTable['purple'] = 24592
- l1 = peripheral.wrap('colorful_lamp_0')
- l2 = peripheral.wrap('colorful_lamp_1')
- c = peripheral.find('chat_box')
- while true do
- event, side, user, message = os.pullEvent('chat_message')
- messageSplit = Split(message, ' ')
- if messageSplit[1] == 'hey' and messageSplit[2] == 'google' and messageSplit[5] == 'lights' then
- color = messageSplit[table.getn(messageSplit)]
- c.say('Ok '..user..', setting lights to '..color)
- l1.setLampColor(colorTable[color])
- l2.setLampColor(colorTable[color])
- else
- c.say("I'm sorry, I don't undersand")
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement