Confusing dechoLink() behavior

Post Reply
aischos
Posts: 7
Joined: Tue Jan 22, 2013 3:48 am

Confusing dechoLink() behavior

Post by aischos » Tue May 07, 2019 7:19 am

Hello all,

The following function is intended to make a large grid (58 X 31) of characters that are individual links that will perform a function based on the x,y coordinates of the clicked character. The function prints the grid correctly but the link actions have the wrong coordinates. If I put a print statement in the function, it prints the expected x and y (q and k) values.
Code: [show] | [select all] lua
function starchart()
	
	for k,v in pairs(zonenames) do
		for q,w in pairs(v) do	
		    dechoLink("starchart", "<0,255,0>"..string.sub(w,1,1),[[print("X,Y:]]..q..","..k..[[")]], q..","..k..": "..w, true)
		end
		decho("starchart","\n")
	end
end
Output (sans links):
Code: [show] | [select all] lua
NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN
NNNNCCCCCCCCCCCCCPCNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN
NNNNCCCCCCCCCCCCCCCNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN
NNNNCCCCCCCCCCCCCCLNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN
NCCCCCCCCCCCFCCCCCCCECCCCCCCCCCNNNNNNNNNNNNNNNNNNNNNNNNNNN
NCCCCCCCCCCCCUCCCCCCCCCCCCCCCCCNNNNNNNNNNNNNNNNNNNNNNNNNNN
NCCCWCCCCCGCCCCCCCCCCCFCCCCCCCCNNNNNNNNNNNNNNNNNNNNNNNNNNN
NCCCCCCCCCCCBCBCCCCFCCCCCCCCCCCCCCNNNNNNNNNNNNNNNNNNNNNNNN
NCCCCCCCCCCCCCCCCNCCCCCCCCCCCCCCCCNNNNNNNNNNNNNNNNNNNNNNNN
NCCCCCCCCCCCCCCICVCDCCCCCCCCCCCCCVNNNNNNNNNNNNNNNNNNNNNNNN
NNNNCCCCCCCCSSCCCCCCCOCCCCCCBCCCCCCCCNNNNNNNNNNNNNNNNNNNNN
NNNNCCCCCC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NNNNNNNNNNNNNNNNNNNRRR
NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNRRR
NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNRRR
Output of clicking each link in the first column.
Code: [show] | [select all] lua
X,Y:51,26    
X,Y:51,27    
X,Y:51,28    
X,Y:51,29    
X,Y:51,30    
X,Y:51,31    
X,Y:15,24    
X,Y:15,25    
X,Y:15,26    
X,Y:15,27    
X,Y:15,28    
X,Y:15,29    
X,Y:15,30    
X,Y:15,31    
X,Y:37,23    
X,Y:37,24    
X,Y:37,25    
X,Y:37,26    
X,Y:37,27    
X,Y:37,28    
X,Y:37,29    
X,Y:37,30    
X,Y:37,31    
X,Y:1,24    
X,Y:1,25    
X,Y:1,27    
X,Y:1,28    
X,Y:1,29    
X,Y:1,30    
X,Y:1,31 
Output from clicking each link the first row.
Code: [show] | [select all] lua
X,Y:51,26    
X,Y:52,26    
X,Y:53,26    
X,Y:54,26    
X,Y:55,26    
X,Y:56,26    
X,Y:57,26    
X,Y:58,26    
X,Y:1,27    
X,Y:2,27    
X,Y:3,27    
X,Y:4,27    
X,Y:5,27    
X,Y:6,27    
X,Y:7,27    
X,Y:8,27    
X,Y:9,27    
X,Y:10,27    
X,Y:11,27    
X,Y:12,27    
X,Y:13,27    
X,Y:14,27    
X,Y:15,27    
X,Y:16,27    
X,Y:17,27    
X,Y:18,27    
X,Y:19,27    
X,Y:20,27    
X,Y:21,27    
X,Y:22,27    
X,Y:23,27    
X,Y:24,27    
X,Y:25,27    
X,Y:26,27    
X,Y:27,27    
X,Y:28,27    
X,Y:29,27    
X,Y:30,27    
X,Y:31,27    
X,Y:32,27    
X,Y:33,27    
X,Y:34,27    
X,Y:35,27    
X,Y:36,27    
X,Y:37,27    
X,Y:38,27    
X,Y:39,27    
X,Y:40,27    
X,Y:41,27    
X,Y:42,27    
X,Y:43,27    
X,Y:44,27    
X,Y:45,27    
X,Y:46,27    
X,Y:47,27    
X,Y:48,27    
X,Y:49,27    
X,Y:50,27  
Some observations that may or may not be helpful:
  • As long as the input table is the same, the incorrect values are always the same (i.e. the top left N is always 51,26 for table "zonename").
  • The links are a repeating pattern. Exactly every 500 grid spots, the pattern begins again with 51,26.
  • X values correctly range between 1-58. Y values range between 23-31.
  • The last 487 links are correct.
I'm at a total loss to understand why it's doing this and am reaching to see if someone more familiar with dechoLink or mudlet in general could provide some guidance.

Jor'Mox
Posts: 1099
Joined: Wed Apr 03, 2013 2:19 am

Re: Confusing dechoLink() behavior

Post by Jor'Mox » Thu May 09, 2019 4:22 pm

When trying to do things in an organized manner, you want to use ipairs, not pairs.

aischos
Posts: 7
Joined: Tue Jan 22, 2013 3:48 am

Re: Confusing dechoLink() behavior

Post by aischos » Sat May 11, 2019 2:58 am

I submitted this as a possible bug here. Vadi's informed me that this is currently intended but changeable behavior.

As far as ipairs vs. pairs, I tried with both and got identical results. Thanks for the check though, you're absolutely right that ipairs is the better choice in this case.

Post Reply

Who is online

Users browsing this forum: Google [Bot] and 11 guests