1. XSSFilter could not parse (X)HTML:
    
    
    
    <p>I've been reading the "World of Warcraft Programming" book, and I'm trying to make that CombatTracker addon work. But whenever I'm logging on, I get the error: Interface\AddOns\CombatTracker\CombatTracker.lua:45: '=' expected near 'CombatTracker_UpdateText'</p>
    
    
    <p>Now I don't know if I'm allowed to post addon code here, but the code we're talking about is this:</p>
    
    
    <p><code>
    <p>-- Set up some local variables to track time and damage<br />local start_time = 0<br />local end_time = 0<br />local total_time = 0<br />local total_damage = 0<br />local average_dps = 0</p>
    
    
    <p>function CombatTracker_OnLoad(frame)<br /> frame:RegisterEvent("UNIT_COMBAT")<br /> frame:RegisterEvent("PLAYER_REGEN_ENABLED")<br /> frame:RegisterEvent("PLAYER_REGEN_DISABLED")<br /> frame:RegisterForClicks("RightButtonUp")<br /> frame:RegisterForDrag("LeftButton")<br />end</p>
    
    
    <p>function CombatTracker_OnEvent(frame, event, ...)<br /> if event == "PLAYER_REGEN_ENABLED" then<br />  -- This event is called when the player exits combat<br />  end_time = GetTime()<br />  total_time = end_time - start_time<br />  average_dps = total_damage / total time<br />  = CombatTracker_UpdateText()<br /> elseif event == "PLAYER_REGEN_DISABLED" then<br />  -- This event is called when we enter combat<br />  -- Reset the damage total and start the timer<br />  CombatTrackerFrameText:SetText("In Combat")<br />  total_damage = 0<br />  start_time = GetTime()<br /> elseif event == "UNIT_COMBAT" then<br />  if not InCombatLockdown() then<br />   -- We are not in combat so ignore the event<br />  else<br />   local unit,action,modifier,damage,damagetype = ...<br />   if unit == "player" and action ~= "HEAL" then<br />    total_damage = total_damage + damage<br />    end_time = GetTime()<br />    total_time = end_time - start_time<br />    average_dps = total_damage / total_time<br />    CombatTracker_UpdateText()<br />   end<br />  end<br /> end<br />end</p>
    
    
    <p>funtion CombatTracker_UpdateText()<br /> local status = string.format("%ds / %d dmg / %.2f DPS", total_time, total_damage, average_dps)<br /> CombatTrackerFrameText:SetText(status)<br />end</p>
    
    
    <p>funtion CombatTracker_ReportDPS()<br /> local msgformat = "%d seconds spent in combat with %d incoming damage. Average incoming DPS was %.2f"<br /> local msg = string.format(msg.format, total_time, total_damage, average_dps)<br /> if GetNumPartyMember() > 0 then<br />  SendChatMessage(msg, "PARTY")<br /> else<br />  ChatFrame1:AddMessage(msg)<br /> end<br />end</p>
    
    <p></code></p></p>
    
    <p>Now I want to know if anyone can help me with this problem, and what I'm doing wrong.</p>
    
    
    <p>Another problem is that the CombatTracker frame won't show up anywhere. I've copied the code directly from the book, and I don't get why it won't work. If anyone can help with that too, then I'd be very grateful ^^</p>
    
    
    XSSFilter could not parse (X)HTML:
    
    
    
    <p>I've been reading the "World of Warcraft Programming" book, and I'm trying to make that CombatTracker addon work. But whenever I'm logging on, I get the error: Interface\AddOns\CombatTracker\CombatTracker.lua:45: '=' expected near 'CombatTracker_UpdateText'</p>
    
    
    <p>Now I don't know if I'm allowed to post addon code here, but the code we're talking about is this:</p>
    
    
    <p><code>
    <p>-- Set up some local variables to track time and damage<br />local start_time = 0<br />local end_time = 0<br />local total_time = 0<br />local total_damage = 0<br />local average_dps = 0</p>
    
    
    <p>function CombatTracker_OnLoad(frame)<br /> frame:RegisterEvent("UNIT_COMBAT")<br /> frame:RegisterEvent("PLAYER_REGEN_ENABLED")<br /> frame:RegisterEvent("PLAYER_REGEN_DISABLED")<br /> frame:RegisterForClicks("RightButtonUp")<br /> frame:RegisterForDrag("LeftButton")<br />end</p>
    
    
    <p>function CombatTracker_OnEvent(frame, event, ...)<br /> if event == "PLAYER_REGEN_ENABLED" then<br />  -- This event is called when the player exits combat<br />  end_time = GetTime()<br />  total_time = end_time - start_time<br />  average_dps = total_damage / total time<br />  = CombatTracker_UpdateText()<br /> elseif event == "PLAYER_REGEN_DISABLED" then<br />  -- This event is called when we enter combat<br />  -- Reset the damage total and start the timer<br />  CombatTrackerFrameText:SetText("In Combat")<br />  total_damage = 0<br />  start_time = GetTime()<br /> elseif event == "UNIT_COMBAT" then<br />  if not InCombatLockdown() then<br />   -- We are not in combat so ignore the event<br />  else<br />   local unit,action,modifier,damage,damagetype = ...<br />   if unit == "player" and action ~= "HEAL" then<br />    total_damage = total_damage + damage<br />    end_time = GetTime()<br />    total_time = end_time - start_time<br />    average_dps = total_damage / total_time<br />    CombatTracker_UpdateText()<br />   end<br />  end<br /> end<br />end</p>
    
    
    <p>funtion CombatTracker_UpdateText()<br /> local status = string.format("%ds / %d dmg / %.2f DPS", total_time, total_damage, average_dps)<br /> CombatTrackerFrameText:SetText(status)<br />end</p>
    
    
    <p>funtion CombatTracker_ReportDPS()<br /> local msgformat = "%d seconds spent in combat with %d incoming damage. Average incoming DPS was %.2f"<br /> local msg = string.format(msg.format, total_time, total_damage, average_dps)<br /> if GetNumPartyMember() > 0 then<br />  SendChatMessage(msg, "PARTY")<br /> else<br />  ChatFrame1:AddMessage(msg)<br /> end<br />end</p>
    
    <p></code></p></p>
    
    <p>Now I want to know if anyone can help me with this problem, and what I'm doing wrong.</p>
    
    
    <p>Another problem is that the CombatTracker frame won't show up anywhere. I've copied the code directly from the book, and I don't get why it won't work. If anyone can help with that too, then I'd be very grateful ^^</p>
    
    

    btw, here it's line 38 it's talking about. I've used some spaces between the code, which have been deleted here, and for some reason, I'm not allowed to edit my post :/

    There are a few issues with the code you've posted.  For reference, you can get the code for the addon itself at the page for the chapter, i.e. http://wowprogramming.com/chapters/12.

    The problem lines are these:

      average_dps = total_damage / total time

      = CombatTracker_UpdateText()

    The first line should read:

    average_dps = total_damage / total_time

    And the second line should read:

    CombatTracker_UpdateText()

    Hopefully that clealrs some things up!

    I'll give it a try and see if it works ^^

    I made it work ^^

    Turns out that you were right, but there were 2 other problems:

    funtion CombatTracker_UpdateText()

    funtion CombatTracker_ReportDPS()

    That's right... I mispelled "function". I wrote "funtion" instead xD

    Ah well, it works now, and that what's important. Thanks again ;)

    Great to hear it!