Fix some lua errors
This commit is contained in:
		
							parent
							
								
									e8abf56b28
								
							
						
					
					
						commit
						9bfd2617e9
					
				
							
								
								
									
										4
									
								
								init.lua
								
								
								
								
							
							
						
						
									
										4
									
								
								init.lua
								
								
								
								
							| 
						 | 
					@ -45,7 +45,3 @@ if g_resources.fileExists("/otclientrc.lua") then
 | 
				
			||||||
  dofile("/otclientrc.lua")
 | 
					  dofile("/otclientrc.lua")
 | 
				
			||||||
end
 | 
					end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
--g_things.loadOtb("/items.otb")
 | 
					 | 
				
			||||||
--g_map.loadOtbm("/forgotten.otbm")
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -39,9 +39,9 @@ function Client.init()
 | 
				
			||||||
  addEvent(function()
 | 
					  addEvent(function()
 | 
				
			||||||
    scheduleEvent(function()
 | 
					    scheduleEvent(function()
 | 
				
			||||||
        -- Play startup music (The Silver Tree, by Mattias Westlund)
 | 
					        -- Play startup music (The Silver Tree, by Mattias Westlund)
 | 
				
			||||||
        g_sounds.playMusic("startup.ogg", 3)
 | 
					        g_sounds.playMusic("/client/startup.ogg", 3)
 | 
				
			||||||
        connect(g_game, { onGameStart = function() g_sounds.stopMusic(3) end })
 | 
					        connect(g_game, { onGameStart = function() g_sounds.stopMusic(3) end })
 | 
				
			||||||
        connect(g_game, { onGameEnd= function() g_sounds.playMusic("startup.ogg", 3) end })
 | 
					        connect(g_game, { onGameEnd= function() g_sounds.playMusic("/client/startup.ogg", 3) end })
 | 
				
			||||||
    end, 100)
 | 
					    end, 100)
 | 
				
			||||||
  end, 0)
 | 
					  end, 0)
 | 
				
			||||||
end
 | 
					end
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -189,22 +189,27 @@ local function onGameStart()
 | 
				
			||||||
  local player = g_game.getLocalPlayer()
 | 
					  local player = g_game.getLocalPlayer()
 | 
				
			||||||
  if(player) then
 | 
					  if(player) then
 | 
				
			||||||
    local char = player:getName()
 | 
					    local char = player:getName()
 | 
				
			||||||
    
 | 
					
 | 
				
			||||||
    local lastChannelsOpen = g_settings.getNode('LastChannelsOpen')
 | 
					    local lastChannelsOpen = g_settings.getNode('LastChannelsOpen')
 | 
				
			||||||
    
 | 
					
 | 
				
			||||||
    if(not table.empty(lastChannelsOpen) and lastChannelsOpen[char]) then
 | 
					    if(not table.empty(lastChannelsOpen) and lastChannelsOpen[char]) then
 | 
				
			||||||
      for channelName, channelId in ipairs(lastChannelsOpen[char]) do
 | 
					      for channelName, channelId in ipairs(lastChannelsOpen[char]) do
 | 
				
			||||||
        if(not table.find(channels, channelId)) then g_game.joinChannel(channelId) end
 | 
					        channelId = tonumber(channelId)
 | 
				
			||||||
 | 
					        if channelId ~= 0 then
 | 
				
			||||||
 | 
					          if not table.find(channels, channelId) then
 | 
				
			||||||
 | 
					            g_game.joinChannel(channelId)
 | 
				
			||||||
 | 
					          end
 | 
				
			||||||
 | 
					        end
 | 
				
			||||||
      end
 | 
					      end
 | 
				
			||||||
    end
 | 
					    end
 | 
				
			||||||
  end
 | 
					  end
 | 
				
			||||||
  
 | 
					
 | 
				
			||||||
  local tab = Console.getTab(tr('Default'))
 | 
					  local tab = Console.getTab(tr('Default'))
 | 
				
			||||||
  if tab then
 | 
					  if tab then
 | 
				
			||||||
    --[[
 | 
					    --[[
 | 
				
			||||||
      Known Issue: The server is calling to open channels after
 | 
					      Known Issue: The server is calling to open channels after
 | 
				
			||||||
      onGameStart is executed causing it to focus the last tab opened.
 | 
					      onGameStart is executed causing it to focus the last tab opened.
 | 
				
			||||||
      
 | 
					
 | 
				
			||||||
      Fix: Don't save channels to the settings that are opened by the server.
 | 
					      Fix: Don't save channels to the settings that are opened by the server.
 | 
				
			||||||
    ]]
 | 
					    ]]
 | 
				
			||||||
    addEvent(function() consoleTabBar:selectTab(tab) end, true)
 | 
					    addEvent(function() consoleTabBar:selectTab(tab) end, true)
 | 
				
			||||||
| 
						 | 
					@ -221,27 +226,27 @@ end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
function Console.clear()
 | 
					function Console.clear()
 | 
				
			||||||
  local lastChannelsOpen = {}
 | 
					  local lastChannelsOpen = {}
 | 
				
			||||||
  
 | 
					
 | 
				
			||||||
  local player = g_game.getLocalPlayer()
 | 
					  local player = g_game.getLocalPlayer()
 | 
				
			||||||
  if(player) then
 | 
					  if(player) then
 | 
				
			||||||
    local char = player:getName()
 | 
					    local char = player:getName()
 | 
				
			||||||
    lastChannelsOpen[char] = {}
 | 
					    lastChannelsOpen[char] = {}
 | 
				
			||||||
    
 | 
					
 | 
				
			||||||
    for channelId, channelName in pairs(channels) do
 | 
					    for channelId, channelName in pairs(channels) do
 | 
				
			||||||
      table.insert(lastChannelsOpen[char], channelId)
 | 
					      table.insert(lastChannelsOpen[char], channelId)
 | 
				
			||||||
    end
 | 
					    end
 | 
				
			||||||
  end
 | 
					  end
 | 
				
			||||||
  
 | 
					
 | 
				
			||||||
  -- save last open channels
 | 
					  -- save last open channels
 | 
				
			||||||
  g_settings.setNode('LastChannelsOpen', lastChannelsOpen)
 | 
					  g_settings.setNode('LastChannelsOpen', lastChannelsOpen)
 | 
				
			||||||
  
 | 
					
 | 
				
			||||||
  for _, channelName in pairs(channels) do
 | 
					  for _, channelName in pairs(channels) do
 | 
				
			||||||
    local tab = consoleTabBar:getTab(channelName)
 | 
					    local tab = consoleTabBar:getTab(channelName)
 | 
				
			||||||
    consoleTabBar:removeTab(tab)
 | 
					    consoleTabBar:removeTab(tab)
 | 
				
			||||||
  end
 | 
					  end
 | 
				
			||||||
  
 | 
					
 | 
				
			||||||
  channels = {}
 | 
					  channels = {}
 | 
				
			||||||
  
 | 
					
 | 
				
			||||||
  consoleTabBar:getTab(tr('Default')).tabPanel:getChildById('consoleBuffer'):destroyChildren()
 | 
					  consoleTabBar:getTab(tr('Default')).tabPanel:getChildById('consoleBuffer'):destroyChildren()
 | 
				
			||||||
  consoleTabBar:getTab(tr('Server Log')).tabPanel:getChildById('consoleBuffer'):destroyChildren()
 | 
					  consoleTabBar:getTab(tr('Server Log')).tabPanel:getChildById('consoleBuffer'):destroyChildren()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue