Question regarding cecholink.

Post Reply
Aconite
Posts: 10
Joined: Sat Mar 31, 2018 1:19 pm

Question regarding cecholink.

Post by Aconite » Thu Apr 05, 2018 9:53 am

I tried to solve this in my way but i couldnt , so im open to any suggestions.

There is a command where i get a response from the mud a list of items in this format.

item_no item_name item_desc

Im using cecholink to reformat this and adding a link to it like (examine item_no)

command and coloring works also hint works , but when i try to click it it always examines the last item( it uses always the last item_no)

Is there a way to solve this?

Thank you.

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

Re: Question regarding cecholink.

Post by Jor'Mox » Thu Apr 05, 2018 11:38 am

To resolve your issue, it would be helpful to see what you are doing when you call cecholink.

Aconite
Posts: 10
Joined: Sat Mar 31, 2018 1:19 pm

Re: Question regarding cecholink.

Post by Aconite » Mon Apr 09, 2018 12:07 pm

This is a few lines from the the bid command output.
### | Current Bid | Time | Level | Min Bid
---------------------------------------------------------------------
606 | 2,000,000 | 182 | 124 | 1,000,000
> the jeweled crown of Aziz-Ra
628 | 0 | 1759 | 50 | 5,000
> an undead squid eye
629 | 0 | 1759 | 52 | 5,000
> an undead squid eye

my Trigger Lines.
^(.+)\| (.+) \| (.+) \| (.+) \| (.+) (| .*) perl regex
^\s+?> (.+) perl regex
it is multiline trigger with line delta 1
This is the lua script

Code: Select all

deleteLine()                            -- delete the current line
moveCursor(0,getLineNumber()-1)  -- move the cursor back one line
deleteLine()                            -- delete the previous line now

-- formatting the bid input 
args = string.split(multimatches[1][1], " | ")
bidname = string.format("%-42s", 		multimatches[2][2]) 
bidno 	= string.format("%-3s",  		args[1]) 
bidcur  = string.format("%-12s", 		args[2])
bidtime	= string.format("%-4s", 		args[3]) 
bidlvl 	= string.format("%-3s" , 	  args[4]) 
bidmin	= string.format("%-12s", 		args[5]) 
echo("\n")
local Al = "Check Bid" .. bidno
cechoLink("<azure>" .. bidno .." " .. bidlvl .." " .. bidname   .."  "..  bidcur  .." ".. bidmin .. " " .. bidtime
, [[send("\n");send("bid " .. bidno)]], Al , true)
if (args[6]) then 
		local match = string.findPattern(args[6], "are the highest")
		if match then
			 cecho("<yellow> <-Bidding")
		else
			 cecho("<yellow> <-Selling") 
		end
end 
echo("\n") 
echo("\n") 


This is the output of the trigger

606 124 the jeweled crown of Aziz-Ra 2,000,000 1,000,000 176

628 50 an undead squid eye 0 5,000 1753

629 52 an undead squid eye 0 5,000 1753

when i hower over first line it shows Check Bid 606
second like Check Bid 628
However, when i click any of the lines it always runs the last line Check Bid 629

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

Re: Question regarding cecholink.

Post by Jor'Mox » Mon Apr 09, 2018 12:45 pm

Yeah, that is a pretty common problem that people run into, actually. The issue here is that the command being sent when you click the link is assembled when you click, rather than when you create the link, because the reference to the bidno variable is inside the literal string (i.e. inside the double square brackets). To fix that, you just need to change the command you are using from this: [[send("\n");send("bid " .. bidno)]]
To this: [[send("\n");send("bid ]] .. bidno .. [[")]]

That way, cecho link is given the VALUE of the variable, rather than a reference to the variable, so that when the value of the variable changes, you won't be changing what is actually getting sent.

User avatar
Vadi
Posts: 4711
Joined: Sat Mar 14, 2009 3:13 pm

Re: Question regarding cecholink.

Post by Vadi » Mon Apr 09, 2018 3:14 pm

We should add functions support to cechoLink - that would also fix things and make it simpler to capture.

Aconite
Posts: 10
Joined: Sat Mar 31, 2018 1:19 pm

Re: Question regarding cecholink.

Post by Aconite » Tue Apr 10, 2018 9:35 pm

Thank you, this solved my problem and i learned something new today.

User avatar
Vadi
Posts: 4711
Joined: Sat Mar 14, 2009 3:13 pm

Re: Question regarding cecholink.

Post by Vadi » Wed Apr 11, 2018 7:41 am

Would you mind adding an example of this to the wiki? Someone else is bound to run into this too.

Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests