+ Reply to Thread
Results 1 to 2 of 2

Thread: Post-Downtime Addon Slash Command Issues

  1. #1
    Soulwalker
    Join Date
    Jan 2018
    Posts
    4

    Default Post-Downtime Addon Slash Command Issues

    Anyone else having issues with addon slash commands after the down time today?

    It seems the command line parameters are not getting sent to the handler as they are supposed to.

    Was working fine for me yesterday, but since the downtime this morning, the slash command gets stuck with whatever parameters I entered the first time.

    Just so any developers with eyes on can see the code in question, below is the slash command handler function.

    Code:
    local function cCore_Sort(handle, cmdline)
    	setFunction("cCore_Sort")
    	print("cCore_Sort(" .. tostring(handle) .. ", " .. cmdline .. ")")
    	if rco then return resetFunction() end
    	
    	rco = {}
    	rco.thread = coroutine.create(gBank.SortVault)
    	rco.hookEnabled = false
    
    	if not rco.hookEnabled then
    		rco.hookEnabled = true
    		Command.Event.Attach(Event.System.Update.Begin, function (handle)
    			if rco == nil then return resetFunction() end
    			if coroutine.status(rco.thread) == "suspended" then
    				print("Resuming... " .. tostring(handle) .. ", " .. cmdline)
    				coroutine.resume(rco.thread, cmdline)
    			elseif coroutine.status(rco.thread) == "dead" then
    				if vault and not vault.sortComplete and #gBank.stack > 0 then
    					print("... I broke something (;_;) ... possibly in " .. gBank.stack[#gBank.stack])
    				end
    				rco = nil
    				vault = {}
    			end
    		end, "Display")
    	end
    	resetFunction()
    end
    -------------------------
    The above results in the following output:
    /ccsort 1
    [cCore] cCore_Sort(table: 0x..., 1) -- This is correct
    [cCore] Resuming.... table: 0x..., 1 -- This is correct on the first run

    /ccsort 2
    [cCore] cCore_Sort(table: 0x..., 2) -- This is correct
    [cCore] Resuming.... table: 0x..., 1 -- This still has the parameter from the first run, even though the event table is different

    Any thoughts?

  2. #2
    Soulwalker
    Join Date
    Jan 2018
    Posts
    4

    Default

    I fixed it by detaching the handler after coroutine death. Code follows for anyone interested.

    Code:
    local function cCore_Sort(handle, cmdline)
    	setFunction("cCore_Sort")
    	print("cCore_Sort(" .. tostring(handle) .. ", " .. cmdline .. ")")
    	if rco then return resetFunction() end
    	
    	rco = {}
    	rco.thread = coroutine.create(gBank.SortVault)
    	rco.hookEnabled = false
    
    	if not rco.hookEnabled then
    		rco.hookEnabled = true
    		function rco.handler(handle)
    			if rco == nil then return resetFunction() end
    			if coroutine.status(rco.thread) == "suspended" then
    				print("Resuming... " .. tostring(handle) .. ", " .. cmdline)
    				coroutine.resume(rco.thread, cmdline)
    			elseif coroutine.status(rco.thread) == "dead" then
    				if vault and not vault.sortComplete and #gBank.stack > 0 then
    					print("... I broke something (;_;) ... possibly in " .. gBank.stack[#gBank.stack])
    				end
    				Command.Event.Detach(Event.System.Update.Begin, rco.handler)
    				rco = nil
    				vault = {}
    				
    			end
    		end
    		Command.Event.Attach(Event.System.Update.Begin, rco.handler, "Display")
    	end
    	resetFunction()
    end

+ Reply to Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts