• 0

    posted a message on localize double quotes
    Hello. Is this the correct way to localize double quotes?

    L["Dread Ship Vazuvius"] = '????????? ??????? "???????"'


    According to wowhead, the ruRU client puts the name vazuvious in quotation marks and I want to make sure I won't run into any lua string operation issues doing it this way.

    http://ru.wowhead.com/npc=73281 for actual name since these forums don't support Cyrillic
    Posted in: Lua Code Discussion
  • 0

    posted a message on russian clients fail string match pattern
    Well anyway, it seems that "[^\(]*" works fine.
    Posted in: Need Help?
  • 0

    posted a message on russian clients fail string match pattern
    I am searching for the following characters in a string, but apparently this is causing problems for the russian client. Is there a better pattern that will work for non-english clients?

    msg is "npc11111: NPC Name (10%) @ 65,67"

    string.match(msg,"[%a%s%-\']*",11)

    The result is NPC Name. The name can include include letters, spaces, hyphens, and apostrophes. I want to match everything up to but not including the open parenthesis and perhaps the space before it for precision. I've tried different patterns but none seem to work as I expect.

    Thoughts?
    Posted in: Need Help?
  • 0

    posted a message on get general chat id
    Thanks for the confirmation. I wasn't sure if I was doing something inappropriate. I'm glad I did it the right way without realizing it ^.^
    Posted in: Need Help?
  • 0

    posted a message on OnUpdate not stopping when set to nil
    Quote from Phanx
    Do you have BugSack running? If not, go get it now before you write another line of code. The default error display cannot show errors that happen during the loading process, which is when 99% of the errors you'll encounter during addon development happen.


    I'll look at this. I am using Swatter so that has helped me quite a bit with error messages.
    Posted in: Need Help?
  • 0

    posted a message on OnUpdate not stopping when set to nil
    Good thoughts. Thanks everyone! I uploaded v1.1.3 this morning. For next revision, I'll consider more housekeeping based on what you said, Phanx. Much of it is left-over from iotrares, so I hope to clean it up more. For now, time for sleep.
    Posted in: Need Help?
  • 0

    posted a message on get general chat id
    Interestingly that code was the first revision I tried after you're first suggestion. It still returned a nil value. I imagine something else in my code is causing this. The problem was the placement of the local generalChat = ... I ended up moving it to another function and it worked fine. Perhaps the channels weren't loaded fast enough before the function was called? Anyway, I appreciate you posting this last bit, it confirmed I was going down the right path.
    Posted in: Need Help?
  • 0

    posted a message on get general chat id
    That enumerates strings. The function returns a string when I need the channel ID for SendChatMessage. I've tried different approaches, also using your idea, but nothing seems to work for me. I don't want to use any libraries. I'll just keep plugging away at it until I figure it out.
    Posted in: Need Help?
  • 0

    posted a message on OnUpdate not stopping when set to nil
    Okay, strange. I updated the getGeneral function and moved it to a lesser line number and now OnUpdate stops running like it's supposed to. I'm stumped...
    Posted in: Need Help?
  • 0

    posted a message on OnUpdate not stopping when set to nil
    I mean, I was just looking for pointers without necessarily getting you to write it for me, but I guess I see your point, and I did link to the code, but here it is again:

    local function update(self,elapsed)
    	timer = timer + elapsed;
    	if timer >= throttle then
    		if mobs[message_mob_id][4] == true then
    			SendChatMessage("npc death reported", "WHISPER", nil, "Nirgáli")
    		elseif mobs[message_mob_id][2] > 0 then -- npc died but not reported
    			SendChatMessage("npc death not reported", "WHISPER", nil, "Nirgáli")
    			SendChatMessage(message , "CHANNEL", nil, general_chat)
    			mobs[message_mob_id][4] = true
    		elseif mobs[message_mob_id][1] + 30 < GetTime() then -- npc spotted but not not reported
    			SendChatMessage("report npc health", "WHISPER", nil, "Nirgáli")
    			SendChatMessage(message , "CHANNEL", nil, general_chat)
    		end
            timer = 0
    		frame:SetScript("OnUpdate", nil)
    	end
    end
    
    local function RandomizeTime()
    	throttle = math.random()*2
    	frame:SetScript("OnUpdate", update)
    end
    
    local function events(frame, event, ...)
    	if event == "COMBAT_LOG_EVENT_UNFILTERED" then
    		local _,event_type,_,_,_,_,_,guid,name = select(1, ...)
    		if event_type == "UNIT_DIED" and guid == UnitGUID("target") then
    			local id = tonumber(guid:sub(6, 10), 16)
    			if not mobs[id] then return end
    			mobs[id][2] = GetTime()
    			mobs[id][3] = name
    			message = "npc"..id..": "..name.." (0%)"
    			message_mob_id = id
    			RandomizeTime()
    		end
    	elseif event == "PLAYER_TARGET_CHANGED" then
    		local guid = UnitGUID("target")
    		if guid and mobs[tonumber(guid:sub(6, 10), 16)] and not UnitIsDead("target") then
    			local id = tonumber(guid:sub(6, 10), 16)
    			local name = UnitName("target")
    			local x, y = GetPlayerMapPosition("player")
    			local hp = math.floor(UnitHealth("target")*100/UnitHealthMax("target"))
    			mobs[id][2] = 0
    			mobs[id][4] = false
    			message = "npc"..id..": "..name.." ("..hp.."%). @ "..math.floor(x*100)..", "..math.floor(y*100)
    			message_mob_id = id
    			RandomizeTime()
    		end
    	elseif event == "CHAT_MSG_CHANNEL" then
    		local msg,_,_,_,_,_,_,channel = select(1, ...)
    		if channel == 1 and string.sub(msg,1,3) == "npc" then
    			local id = tonumber(string.sub(msg,4,8))
    			if mobs[id] then 
    				mobs[id][1] = GetTime()
    				if string.find(msg,'%(0%%%)') then 
    					mobs[id][2] = GetTime()
    					mobs[id][4] = true
    					mobs[id][3] = string.match(msg,"[%a%s%-\']*",11)
    				else
    					mobs[id][2] = 0
    					mobs[id][4] = false
    				end
    			end
    		end
    	elseif(event == "PLAYER_ENTERING_WORLD" or event == "ZONE_CHANGED_NEW_AREA") then
    		init()
    	end
    end
    Posted in: Need Help?
  • 0

    posted a message on OnUpdate not stopping when set to nil
    Yo, fellow coders!

    Moved this from unrelated topic. I added some context as well (the calling function) albeit a in very brief form.

    The dev branch code can be found here with all my recent test hacks:
    https://github.com/Nirgali42/MoPRares/blob/dev/MoPRares.lua

    When does frame:SetScript("OnUpdate", nil) not work? It continues to flood me after the first condition is met. Any thoughts?

    local frame = CreateFrame("Frame", nil, UIParent)
    local timer, throttle
    local function update(self,elapsed)
    	timer = timer + elapsed;
    	if timer >= throttle then
    		if condition_is_met then
                            SendChatMessage("condition met", "WHISPER", nil, "PlayerName")
    			timer = 0
    			frame:SetScript("OnUpdate", nil)
    			return
                    end
                    if another_condition_is_met then
                            SendChatMessage("another condition met", "WHISPER", nil, "PlayerName")
            	end
            	timer = 0
    		frame:SetScript("OnUpdate", nil)
             end
    end
    
    local function RandomizeTime()
    	throttle = math.random()*2
    	frame:SetScript("OnUpdate", update)
    end
    
    local function events(frame, event, ...)
    	if event == "COMBAT_LOG_EVENT_UNFILTERED" then
    		local _,event_type,_,_,_,_,_,guid,name = select(1, ...)
    		if event_type == "UNIT_DIED" and guid == UnitGUID("target") then
    			-- perform test and set condition_is_met here
    			RandomizeTime()
    		end
    	elseif event == "PLAYER_TARGET_CHANGED" then
    		-- perform test and set another_condition_is_met here
    		RandomizeTime()
            end
    end
    Posted in: Need Help?
  • 0

    posted a message on get general chat id
    My dev branch has the latest hacking I've done, including debugging and such.
    https://github.com/Nirgali42/MoPRares/blob/dev/MoPRares.lua
    Posted in: Need Help?
  • 0

    posted a message on get general chat id
    Haha. I started writing this for a different reason and it became something completely different. I fixed the first post to meet the topic title since I couldn't change the title.
    Posted in: Need Help?
  • 0

    posted a message on get general chat id
    Yo!

    I am beating this with a large stick and it doesn't seem to do what I expect. Any pointers are appreciated.

    Basically, I want to get the general chat id, so I loop through the list of channels looking for one that starts with General. Is there a better way to write this perhaps?

    Dev branch code here: https://github.com/Nirgali42/MoPRares/blob/dev/MoPRares.lua

    local function getGeneral(...)
    	for i = 1, select("#", ...), 2 do
    		local id, name = select(i, ...)
    		if not string.match(name,'General', ...) == nil then 
    			SendChatMessage(name..":"..id, "WHISPER", nil, "Nirgáli")
    			return id
    		end
    	end
    end	
    local general_chat = getGeneral(GetChannelList())
    Posted in: Need Help?
  • 0

    posted a message on addon not in search results on curse.com
    Looks like it only takes up to 24 hours. Yay!
    Posted in: Need Help?
  • To post a comment, please or register a new account.