diff options
| author | 1029chris <1029chris@gmail.com> | 2016-03-08 17:40:10 -0800 |
|---|---|---|
| committer | 1029chris <1029chris@gmail.com> | 2016-03-08 17:40:10 -0800 |
| commit | 5e6570f4a189a4bcfab79ecf88fbd0df22be023e (patch) | |
| tree | 27e74d5c16b6ace958488d4c4a35d9b248dcca4c /chat.lua | |
| parent | 414afd442a21455027f052e5cc849091d60a777d (diff) | |
Worked more on chat, optimized code.
Diffstat (limited to 'chat.lua')
| -rw-r--r-- | chat.lua | 31 |
1 files changed, 22 insertions, 9 deletions
@@ -19,15 +19,16 @@ function drawChat() love.graphics.draw(chat.profile, 6, 30) love.graphics.setColor(colors.font.dark) love.graphics.print(chat.profilename, 50, 41) - love.graphics.setColor(colors.font.friend) - if #msg.msgs <= 15 then - for i=1,#msg.msgs do - love.graphics.print("Friend: " .. msg.msgs[i], 12, 310 - (15*i)) - end - elseif #msg.msgs >= 15 then - for i=1,15 do - love.graphics.print("Friend: " .. msg.msgs[i], 12, 310 - (15*i)) + for i=1,chatlimit() do + if msg.msgs[i][1] == 1 then + love.graphics.setColor(colors.font.friend) + love.graphics.print("Friend:", 12, 310 - (28*i)) + elseif msg.msgs[i][1] == 2 then + love.graphics.setColor(colors.font.you) + love.graphics.print("You:", 12, 310 - (28*i)) end + love.graphics.setColor(colors.font.dark) + love.graphics.print("\n" .. msg.msgs[i][2], 12, 310 - (28*i)) end end function updateChat() @@ -36,5 +37,17 @@ function updateChat() msg.new = false end end -function sendMessage(message) +function sendMessage(id, message) + msg.new = true + table.insert(msg.msgs, 1, {id, message}) + if win[1].ex == true or layer[1] ~= 1 then + notifyNow("CHAT NOTIFICATION", "New message from\nBest Friend:\n\n" .. message) + end +end +function chatlimit() + if #msg.msgs <=8 then + return #msg.msgs + else + return 8 + end end |
