Skip to content
Snippets Groups Projects
Commit ac0e5241 authored by dg's avatar dg
Browse files

chat more

Eruan got nice palmtrees tiles


git-svn-id: http://svn.net-core.org/repos/t-engine4@2785 51575b47-30f0-44d4-a5cc-537603b46e54
parent 8eb0bf9b
No related branches found
No related tags found
No related merge requests found
Showing
with 293 additions and 35 deletions
......@@ -23,3 +23,10 @@ defineAction{
group = "user chat",
name = "Talk to people",
}
defineAction{
default = { "sym:32:true:false:false:false" },
type = "USERCHAT_SHOW_TALK",
group = "user chat",
name = "Display chat log",
}
......@@ -269,7 +269,10 @@ function _M:instanciate(mod, name, new_game, no_reboot)
_G.game:run()
-- Add user chat if needed
if mod.allow_userchat and _G.game.key then profile.chat:setupOnGame() end
if mod.allow_userchat and _G.game.key then
profile.chat:setupOnGame()
profile.chat:join(mod.short_name)
end
-- Disable the profile if ungood
if mod.short_name ~= "boot" then
......
......@@ -20,14 +20,25 @@
require "engine.class"
require "engine.ui.Base"
local KeyBind = require "engine.KeyBind"
local Mouse = require "engine.Mouse"
--- Module that handles multiplayer chats
module(..., package.seeall, class.inherit(engine.ui.Base))
local ls, ls_w, ls_h = _M:getImage("ui/selection-left-sel.png")
local ms, ms_w, ms_h = _M:getImage("ui/selection-middle-sel.png")
local rs, rs_w, rs_h = _M:getImage("ui/selection-right-sel.png")
local l, l_w, l_h = _M:getImage("ui/selection-left.png")
local m, m_w, m_h = _M:getImage("ui/selection-middle.png")
local r, r_w, r_h = _M:getImage("ui/selection-right.png")
--- Creates the log zone
function _M:init()
self.changed = true
self.channels_changed = true
self.cur_channel = "global"
self.channels = {}
self.max = 50
end
--- Hook up in the current running game
......@@ -51,18 +62,39 @@ function _M:event(e)
self.channels[e.channel] = self.channels[e.channel] or {users={}, log={}}
local log = self.channels[e.channel].log
table.insert(log, 1, ("<%s> %s"):format(e.user, e.msg))
while #log > 50 do table.remove(log) end
game.log("#YELLOW#"..log[1])
table.insert(log, 1, {user=e.user, msg=e.msg})
while #log > self.max do table.remove(log) end
self.changed = true
elseif e.se == "Join" then
self.channels[e.channel] = self.channels[e.channel] or {users={}, log={}}
self.channels[e.channel].users[e.user] = true
self.channels_changed = true
elseif e.se == "Part" then
self.channels[e.channel] = self.channels[e.channel] or {users={}, log={}}
self.channels[e.channel].users[e.user] = nil
self.channels_changed = true
elseif e.se == "UserInfo" then
local info = e.data:unserialize()
if not info then return end
end
end
function _M:join(channel)
if not profile.auth then return end
core.profile.pushOrder(string.format("o='ChatJoin' channel=%q", channel))
self.cur_channel = channel
self.channels[channel] = self.channels[channel] or {users={}, log={}}
self.channels_changed = true
self.changed = true
end
function _M:selectChannel(channel)
if not self.channels[channel] then return end
self.cur_channel = channel
self.channels_changed = true
self.changed = true
end
function _M:talk(msg)
if not profile.auth then return end
if not msg then return end
......@@ -70,12 +102,169 @@ function _M:talk(msg)
core.profile.pushOrder(string.format("o='ChatTalk' channel=%q msg=%q", self.cur_channel, msg))
end
function _M:getUserInfo(user)
if not profile.auth then return end
if not user then return end
core.profile.pushOrder(string.format("o='ChatUserInfo' user=%q", user))
end
--- Request a line to send
-- TODO: make it betetr than a simple dialog
-- TODO: make it better than a simple dialog
function _M:talkBox()
if not profile.auth then return end
local d = require("engine.dialogs.GetText").new("Talk", self.cur_channel, 0, 250, function(text)
self:talk(text)
end)
d.key:addBind("EXIT", function() game:unregisterDialog(d) end)
game:registerDialog(d)
end
----------------------------------------------------------------
-- UI Section
----------------------------------------------------------------
--- Resize the display area
function _M:resize(x, y, w, h, fontname, fontsize, color, bgcolor)
self.color = color or {255,255,255}
if type(bgcolor) ~= "string" then
self.bgcolor = bgcolor or {0,0,0}
else
self.bgcolor = {0,0,0}
self.bg_image = bgcolor
end
self.font = core.display.newFont(fontname or "/data/font/Vera.ttf", fontsize or 12)
self.font_h = self.font:lineSkip()
self.scroll = 0
self.changed = true
self.display_x, self.display_y = math.floor(x), math.floor(y)
self.w, self.h = math.floor(w), math.floor(h)
self.fw, self.fh = self.w - 4, self.font:lineSkip()
self.max_display = math.floor(self.h / self.fh)
if self.bg_image then
local fill = core.display.loadImage(self.bg_image)
local fw, fh = fill:getSize()
self.bg_surface = core.display.newSurface(w, h)
self.bg_surface:erase(0, 0, 0)
for i = 0, w, fw do for j = 0, h, fh do
self.bg_surface:merge(fill, i, j)
end end
self.bg_texture, self.bg_texture_w, self.bg_texture_h = self.bg_surface:glTexture()
end
local sb, sb_w, sb_h = self:getImage("ui/scrollbar.png")
local ssb, ssb_w, ssb_h = self:getImage("ui/scrollbar-sel.png")
self.scrollbar = { bar = {}, sel = {} }
self.scrollbar.sel.w, self.scrollbar.sel.h, self.scrollbar.sel.tex, self.scrollbar.sel.texw, self.scrollbar.sel.texh = ssb_w, ssb_h, ssb:glTexture()
local s = core.display.newSurface(sb_w, self.h)
s:erase(200,0,0)
for i = 0, self.h do s:merge(sb, 0, i) end
self.scrollbar.bar.w, self.scrollbar.bar.h, self.scrollbar.bar.tex, self.scrollbar.bar.texw, self.scrollbar.bar.texh = ssb_w, self.h, s:glTexture()
self.mouse = Mouse.new()
self.mouse.delegate_offset_x = self.display_x
self.mouse.delegate_offset_y = self.display_y
self.mouse:registerZone(0, 0, self.w, self.h, function(button, x, y, xrel, yrel, bx, by, event)
if event == "button" and button == "left" and y <= ls_h then
local w = 0
local last_ok = nil
for i = 1, #self.display_chans do
local item = self.display_chans[i]
last_ok = item
w = w + item.w + 4
if w > x then break end
end
if last_ok then self:selectChannel(last_ok.name) end
end
end)
end
function _M:display()
-- Changed channels list
if self.channels_changed then
self.display_chans = {}
local list = {}
for name, data in pairs(self.channels) do list[#list+1] = name end
table.sort(list, function(a,b) if a == "global" then return 1 elseif b == "global" then return nil else return a < b end end)
for i, name in ipairs(list) do
local oname = name
name = "["..name:capitalize().." ("..#self.channels[name].users..")]"
local len = self.font_mono:size(name)
local s = core.display.newSurface(len + ls_w + rs_w, ls_h)
s:erase(0, 0, 0, 0)
if oname == self.cur_channel then
s:merge(ls, 0, 0)
for i = ls_w, len + ls_w, ms_w do s:merge(ms, i, 0) end
s:merge(rs, len + ls_w, 0)
end
s:drawColorStringBlended(self.font_mono, name, ls_w, (ls_h - self.font_mono_h) / 2, 0x8d, 0x55, 0xff, oname ~= self.cur_channel, len)
local item = {name=oname, w=len + ls_w + rs_w, h=ls_h}
item._tex, item._tex_w, item._tex_h = s:glTexture()
self.display_chans[#self.display_chans+1] = item
end
self.channels_changed = false
end
-- If nothing changed, return the same surface as before
if not self.changed then return end
self.changed = false
-- Erase and the display
self.dlist = {}
local h = 0
local log = {}
if self.channels[self.cur_channel] then log = self.channels[self.cur_channel].log end
local old_style = self.font:getStyle()
for z = 1 + self.scroll, #log do
local stop = false
local tstr = ("<%s> %s"):format(log[z].user, log[z].msg)
local gen = tstring.makeLineTextures(tstr, self.w - 4, self.font_mono)
for i = #gen, 1, -1 do
self.dlist[#self.dlist+1] = gen[i]
h = h + self.fh
if h > self.h - self.fh - ls_h then stop=true break end
end
if stop then break end
end
self.font:setStyle(old_style)
return
end
function _M:toScreen()
self:display()
if self.bg_texture then self.bg_texture:toScreenFull(self.display_x, self.display_y, self.w, self.h, self.bg_texture_w, self.bg_texture_h) end
local h = self.display_y + self.h - self.fh
for i = 1, #self.dlist do
local item = self.dlist[i]
item._tex:toScreenFull(self.display_x, h, self.fw, self.fh, item._tex_w, item._tex_h)
h = h - self.fh
end
local w = 0
for i = 1, #self.display_chans do
local item = self.display_chans[i]
item._tex:toScreenFull(self.display_x + w, self.display_y, item.w, item.h, item._tex_w, item._tex_h)
w = w + item.w + 4
end
if true then
local pos = self.scroll * (self.h - self.fh) / (self.max - self.max_display + 1)
self.scrollbar.bar.tex:toScreenFull(self.display_x + self.w - self.scrollbar.bar.w, self.display_y, self.scrollbar.bar.w, self.scrollbar.bar.h, self.scrollbar.bar.texw, self.scrollbar.bar.texh)
self.scrollbar.sel.tex:toScreenFull(self.display_x + self.w - self.scrollbar.sel.w, self.display_y + self.h - self.scrollbar.sel.h - pos, self.scrollbar.sel.w, self.scrollbar.sel.h, self.scrollbar.sel.texw, self.scrollbar.sel.texh)
end
end
--- Scroll the zone
-- @param i number representing how many lines to scroll
function _M:scrollUp(i)
self.scroll = self.scroll + i
if self.scroll > #self.log - 1 then self.scroll = #self.log - 1 end
if self.scroll < 0 then self.scroll = 0 end
self.changed = true
end
......@@ -83,10 +83,11 @@ function _M:run()
self.delayed_log_damage = {}
self.calendar = Calendar.new("/data/calendar_allied.lua", "Today is the %s %s of the %s year of the Age of Ascendancy of Maj'Eyal.\nThe time is %02d:%02d.", 122, 167, 11)
self.flash = LogFlasher.new(0, 0, self.w, 20, nil, "/data/font/USENET_.ttf", 16, {255,255,255}, {0,0,0})
self.logdisplay = LogDisplay.new(0, self.h * 0.8 + 7, self.w * 0.5 - 30, self.h * 0.2 - 7, nil, "/data/font/USENET_.ttf", 15, {255,255,255}, "/data/gfx/ui/message-log.png")
self.logdisplay = LogDisplay.new(0, self.h * 0.8 + 7, self.w * 0.5 - 46, self.h * 0.2 - 7, nil, "/data/font/USENET_.ttf", 15, {255,255,255}, "/data/gfx/ui/message-log.png")
profile.chat:resize(0, self.h * 0.8 + 7, self.w * 0.5 - 46, self.h * 0.2 - 7, "/data/font/USENET_.ttf", 15, {255,255,255}, "/data/gfx/ui/message-log.png")
self.player_display = PlayerDisplay.new(0, 230, 200, self.h * 0.8 - 230, {30,30,0})
self.hotkeys_display = HotkeysDisplay.new(nil, self.w * 0.5 + 30, self.h * 0.8 + 7, self.w * 0.5 - 30, self.h * 0.2 - 7, "/data/gfx/ui/talents-list.png", "/data/font/SVBasicManual.ttf", 14)
self.npcs_display = ActorsSeenDisplay.new(nil, self.w * 0.5 + 30, self.h * 0.8 + 7, self.w * 0.5 - 30, self.h * 0.2 - 7, "/data/gfx/ui/talents-list.png", "/data/font/SVBasicManual.ttf", 14)
self.hotkeys_display = HotkeysDisplay.new(nil, self.w * 0.5 + 46, self.h * 0.8 + 7, self.w * 0.5 - 46, self.h * 0.2 - 7, "/data/gfx/ui/talents-list.png", "/data/font/SVBasicManual.ttf", 14)
self.npcs_display = ActorsSeenDisplay.new(nil, self.w * 0.5 + 46, self.h * 0.8 + 7, self.w * 0.5 - 46, self.h * 0.2 - 7, "/data/gfx/ui/talents-list.png", "/data/font/SVBasicManual.ttf", 14)
self.tooltip = Tooltip.new("/data/font/SVBasicManual.ttf", 16, {255,255,255}, {30,30,30,230})
self.tooltip2 = Tooltip.new(nil, nil, {255,255,255}, {30,30,30,230})
self.flyers = FlyingText.new("/data/font/INSULA__.ttf", 14, "/data/font/INSULA__.ttf", 17)
......@@ -792,7 +793,10 @@ function _M:display(nb_keyframes)
-- We display the player's interface
self.flash:toScreen(nb_keyframe)
self.logdisplay:toScreen()
if self.show_userchat then profile.chat:toScreen()
else self.logdisplay:toScreen()
end
self.player_display:toScreen()
if self.show_npc_list then
self.npcs_display:toScreen()
......@@ -1078,6 +1082,10 @@ function _M:setupCommands()
local ok, err = coroutine.resume(co)
if not ok and err then print(debug.traceback(co)) error(err) end
end,
USERCHAT_SHOW_TALK = function()
self.show_userchat = not self.show_userchat
end
}
self.key:setCurrent()
......@@ -1099,10 +1107,14 @@ function _M:setupMouse(reset)
self.player:mouseHandleDefault(self.key, self.key == self.normal_key, button, mx, my, xrel, yrel, event)
end)
-- Scroll message log
self.mouse:registerZone(self.logdisplay.display_x, self.logdisplay.display_y, self.w, self.h, function(button)
if button == "wheelup" then self.logdisplay:scrollUp(1) end
if button == "wheeldown" then self.logdisplay:scrollUp(-1) end
end, {button=true})
self.mouse:registerZone(self.logdisplay.display_x, self.logdisplay.display_y, self.w, self.h, function(button, mx, my, xrel, yrel, bx, by, event)
if self.show_userchat then
profile.chat.mouse:delegate(button, mx, my, xrel, yrel, bx, by, event)
else
if button == "wheelup" then self.logdisplay:scrollUp(1) end
if button == "wheeldown" then self.logdisplay:scrollUp(-1) end
end
end)
-- Use hotkeys with mouse
self.mouse:registerZone(self.hotkeys_display.display_x, self.hotkeys_display.display_y, self.w, self.h, function(button, mx, my, xrel, yrel, bx, by, event)
if event == "button" and button == "left" and self.zone and self.zone.wilderness then return end
......@@ -1290,6 +1302,8 @@ local _sep_bottoml = {core.display.loadImage("/data/gfx/ui/separator-bottom_line
local _sep_leftl = {core.display.loadImage("/data/gfx/ui/separator-left_line_end.png")} _sep_leftl.tex = {_sep_leftl[1]:glTexture()}
local _sep_rightl = {core.display.loadImage("/data/gfx/ui/separator-right_line_end.png")} _sep_rightl.tex = {_sep_rightl[1]:glTexture()}
local _log_icon, _log_icon_w, _log_icon_h = core.display.loadImage("/data/gfx/ui/log-icon.png"):glTexture()
local _chat_icon, _chat_icon_w, _chat_icon_h = core.display.loadImage("/data/gfx/ui/chat-icon.png"):glTexture()
local _talents_icon, _talents_icon_w, _talents_icon_h = core.display.loadImage("/data/gfx/ui/talents-icon.png"):glTexture()
local _actors_icon, _actors_icon_w, _actors_icon_h = core.display.loadImage("/data/gfx/ui/actors-icon.png"):glTexture()
local _main_menu_icon, _main_menu_icon_w, _main_menu_icon_h = core.display.loadImage("/data/gfx/ui/main-menu-icon.png"):glTexture()
......@@ -1301,22 +1315,33 @@ function _M:displayUI()
local middle = self.w * 0.5
local bottom = self.h * 0.8
local bottom_h = self.h * 0.2
local icon_x = middle - (_talents_icon_w) / 2
local icon_x2 = middle + (_talents_icon_w) / 2
local icon_x = middle - (_talents_icon_w*2) / 2
local icon_x2 = middle + (_talents_icon_w*2) / 2
local mid_min = icon_x - (_sep_vert[2])
local mid_max = icon_x2
-- Icons
local x, y = icon_x, bottom + _sep_horiz[3] / 2
_talents_icon:toScreenFull(x, y, _talents_icon_w, _talents_icon_h, _talents_icon_w, _talents_icon_h)
if not self.show_npc_list then _sel_icon:toScreenFull(x, y, _sel_icon_w, _sel_icon_h, _sel_icon_w, _sel_icon_h) end
_talents_icon:toScreenFull(x + _talents_icon_w, y, _talents_icon_w, _talents_icon_h, _talents_icon_w, _talents_icon_h)
if not self.show_npc_list then _sel_icon:toScreenFull(x + _talents_icon_w, y, _sel_icon_w, _sel_icon_h, _sel_icon_w, _sel_icon_h) end
y = y + _talents_icon_h
_actors_icon:toScreenFull(x, y, _actors_icon_w, _actors_icon_h, _actors_icon_w, _actors_icon_h)
if self.show_npc_list then _sel_icon:toScreenFull(x, y, _sel_icon_w, _sel_icon_h, _sel_icon_w, _sel_icon_h) end
_actors_icon:toScreenFull(x + _talents_icon_w, y, _actors_icon_w, _actors_icon_h, _actors_icon_w, _actors_icon_h)
if self.show_npc_list then _sel_icon:toScreenFull(x + _talents_icon_w, y, _sel_icon_w, _sel_icon_h, _sel_icon_w, _sel_icon_h) end
y = y + _talents_icon_h
_inventory_icon:toScreenFull(x, y, _inventory_icon_w, _inventory_icon_h, _inventory_icon_w, _inventory_icon_h) y = y + _inventory_icon_h
_charsheet_icon:toScreenFull(x, y, _charsheet_icon_w, _charsheet_icon_h, _charsheet_icon_w, _charsheet_icon_h) y = y + _charsheet_icon_h
_main_menu_icon:toScreenFull(x, y, _main_menu_icon_w, _main_menu_icon_h, _main_menu_icon_w, _main_menu_icon_h) y = y + _main_menu_icon_h
local x, y = icon_x, bottom + _sep_horiz[3] / 2
_log_icon:toScreenFull(x, y, _log_icon_w, _log_icon_h, _log_icon_w, _log_icon_h)
if not self.show_userchat then _sel_icon:toScreenFull(x, y, _sel_icon_w, _sel_icon_h, _sel_icon_w, _sel_icon_h)
elseif self.logdisplay.changed then core.display.drawQuad(x, y, _sel_icon_w, _sel_icon_h, 128, 128, 128, 128) end
y = y + _log_icon_h
_chat_icon:toScreenFull(x, y, _chat_icon_w, _chat_icon_h, _chat_icon_w, _chat_icon_h)
if self.show_userchat then _sel_icon:toScreenFull(x, y, _sel_icon_w, _sel_icon_h, _sel_icon_w, _sel_icon_h)
elseif profile.chat.changed then core.display.drawQuad(x, y, _sel_icon_w, _sel_icon_h, 128, 128, 128, 128) end
y = y + _chat_icon_h
_inventory_icon:toScreenFull(x + _talents_icon_w/2, y, _inventory_icon_w, _inventory_icon_h, _inventory_icon_w, _inventory_icon_h) y = y + _inventory_icon_h
_charsheet_icon:toScreenFull(x + _talents_icon_w/2, y, _charsheet_icon_w, _charsheet_icon_h, _charsheet_icon_w, _charsheet_icon_h) y = y + _charsheet_icon_h
_main_menu_icon:toScreenFull(x + _talents_icon_w/2, y, _main_menu_icon_w, _main_menu_icon_h, _main_menu_icon_w, _main_menu_icon_h) y = y + _main_menu_icon_h
-- Separators
_sep_horiz.tex[1]:toScreenFull(0, 20, self.w, _sep_horiz[3], _sep_horiz.tex[2], _sep_horiz.tex[3])
......@@ -1349,20 +1374,28 @@ function _M:createSeparators()
local bottom = self.h * 0.8
local bottom_h = self.h * 0.2
self.icons = {
display_x = middle - (_talents_icon_w) / 2,
display_x = middle - (_talents_icon_w*2) / 2,
display_y = bottom + _sep_horiz[3] / 2,
w = _talents_icon_w,
w = _talents_icon_w*2,
h = 5*_talents_icon_h
}
end
function _M:clickIcon(bx, by)
if by < _talents_icon_h then
self.show_npc_list = false
self.player.changed = true
if bx >= _talents_icon_w then
self.show_npc_list = false
self.player.changed = true
else
self.show_userchat = false
end
elseif by < 2*_talents_icon_h then
self.show_npc_list = true
self.player.changed = true
if bx >= _talents_icon_w then
self.show_npc_list = true
self.player.changed = true
else
self.show_userchat = true
end
elseif by < 3*_talents_icon_h then
self.key:triggerVirtual("SHOW_INVENTORY")
elseif by < 4*_talents_icon_h then
......@@ -1374,9 +1407,17 @@ end
function _M:mouseIcon(bx, by)
if by < _talents_icon_h then
self.tooltip:displayAtMap(nil, nil, self.w, self.h, "Display talents")
if bx >= _talents_icon_w then
self.tooltip:displayAtMap(nil, nil, self.w, self.h, "Display talents\nToggle with [tab]")
else
self.tooltip:displayAtMap(nil, nil, self.w, self.h, "Display game log\nToggle with [ctrl+space]")
end
elseif by < 2*_talents_icon_h then
self.tooltip:displayAtMap(nil, nil, self.w, self.h, "Display creatures")
if bx >= _talents_icon_w then
self.tooltip:displayAtMap(nil, nil, self.w, self.h, "Display creatures\nToggle with [tab]")
else
self.tooltip:displayAtMap(nil, nil, self.w, self.h, "Display community chat\nToggle with [ctrl+space]")
end
elseif by < 3*_talents_icon_h then
self.tooltip:displayAtMap(nil, nil, self.w, self.h, "Inventory")
elseif by < 4*_talents_icon_h then
......
......@@ -200,20 +200,20 @@ newEntity{ base = "SANDWALL_STABLE", define_as = "SANDWALL_STABLE_PILLAR_6"..i,
newEntity{ base = "SANDWALL_STABLE", define_as = "SANDWALL_STABLE_HOLE_2"..i, image = "terrain/sandwall_2h_"..i..".png"}
newEntity{ base = "SANDWALL_STABLE", define_as = "SANDWALL_STABLE_HOLE_8"..i, image = "terrain/sandwall_5_"..i..".png", add_displays = {class.new{image="terrain/sandwall_8h_1.png", z=18, display_y=-1}}}
for i = 1, 20 do
newEntity{
define_as = "PALMTREE",
define_as = "PALMTREE"..(i > 1 and i or ""),
type = "wall", subtype = "sand",
name = "tree", image = "terrain/sandfloor.png",
display = '#', color=colors.LIGHT_GREEN, back_color={r=93,g=79,b=22},
-- add_displays = class:makeTrees("terrain/palmtree_alpha", 1),
add_displays = {class.new{image="terrain/palmtree_alpha1.png"}},
add_displays = class:makeTrees("terrain/palmtree_alpha", 4),
always_remember = true,
can_pass = {pass_tree=1},
does_block_move = true,
block_sight = true,
dig = "SAND",
}
end
-----------------------------------------
-- Sandy exits
......
game/modules/tome/data/gfx/shockbolt/terrain/palmtree_alpha1.png

5.24 KiB

game/modules/tome/data/gfx/shockbolt/terrain/palmtree_alpha2.png

3.84 KiB

game/modules/tome/data/gfx/shockbolt/terrain/palmtree_alpha3.png

7.26 KiB

game/modules/tome/data/gfx/shockbolt/terrain/palmtree_alpha4.png

7.88 KiB

game/modules/tome/data/gfx/ui/chat-icon.png

1.55 KiB

game/modules/tome/data/gfx/ui/log-icon.png

1.55 KiB

......@@ -38,7 +38,7 @@ return {
sqrt_percent = 40,
noise = "fbm_perlin",
floor = "SAND",
wall = "PALMTREE",
wall = {"PALMTREE","PALMTREE2","PALMTREE3","PALMTREE4","PALMTREE5","PALMTREE6","PALMTREE7","PALMTREE8","PALMTREE9","PALMTREE10","PALMTREE11","PALMTREE12","PALMTREE13","PALMTREE14","PALMTREE15","PALMTREE16","PALMTREE17","PALMTREE18","PALMTREE19","PALMTREE20",},
up = "SAND_UP8",
down = "SAND_DOWN2",
do_ponds = {
......
......@@ -54,6 +54,7 @@ end
function _M:disconnect()
self.sock = nil
self.auth = nil
core.game.sleep(5000) -- Wait 5 secs
end
function _M:read(ncode)
......@@ -78,6 +79,7 @@ function _M:pread(ncode)
if err == "closed" then
print("[PROFILE] push connection disrupted, trying to reconnect", err)
self.psock = nil
core.game.sleep(5000) -- Wait 5 secs
end
return nil
end
......@@ -266,6 +268,22 @@ function _M:orderChatTalk(o)
self:read("200")
end
function _M:orderChatJoin(o)
self:command("JOIN", o.channel)
self:read("200")
end
function _M:orderChatUserInfo(o)
self:command("UINF", o.user)
if self:read("200") then
local _, _, size = self.last_line:find("^([0-9]+)")
size = tonumber(size)
if not size or size < 1 then return end
local body = self.sock:receive(size)
cprofile.pushEvent(string.format("e='Chat' se='UserInfo' user=%q data=%q", o.user, body))
end
end
--------------------------------------------------------------------
-- Pushes comming from the push socket
--------------------------------------------------------------------
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment