echoLink iteration

Post Reply
Silvine
Posts: 142
Joined: Sat Oct 23, 2010 2:36 pm

echoLink iteration

Post by Silvine »

Hi, I'm trying to iterate through a table to create a series clickable links. But when I clink on a link, the correct value displays from the table but all the links refer to the last value in the table. Does echoLink not store the value assigned to it on creation?

cechoLink( "<cyan>view room "..viewRoom[vcount], [[centerview(viewRoom[vcount])]], "Center Map on room",true)

the links are displaying

view room 14159
view room 14248
view room 14129

but clicking any link shows 14129

thanks
Last edited by Silvine on Wed Dec 18, 2013 10:25 am, edited 1 time in total.

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

Re: echoLink help

Post by Vadi »

"Does echoLink not store the value assigned to it on creation?" that's not what your syntax is telling it to do. It's telling it to, when the code is running, to then check the value of vcount and use it as the index.

Try instead:
Code: [show] | [select all] lua
cechoLink( "<cyan>view room "..viewRoom[vcount], [[centerview(viewRoom[]] .. vcount .. [[])]], "Center Map on room",true)
That is assuming vcount is a number and not text.

Silvine
Posts: 142
Joined: Sat Oct 23, 2010 2:36 pm

Re: echoLink iteration

Post by Silvine »

Ah yes!!! Schoolboy error :)

Many Thanks

Silvine
Posts: 142
Joined: Sat Oct 23, 2010 2:36 pm

Re: echoLink iteration

Post by Silvine »

Turns out I need some more schooling.
I have the following line

Code: Select all

cechoLink( "<pink> "..resultsWorn.."\n", [[echo("ItemBox", "\n----------------------------\n"..resultsDB[1].Entire)]],resultsDB[1].Entire,true)
and it shows the last value for resultsDB[1].Entire
as a trigger fires, so I thought I needed the following

Code: Select all

cechoLink( "<pink> "..resultsWorn.."\n", [[echo("ItemBox", "\n----------------------------\n"..]]..resultsDB[1].Entire..[[)]],resultsDB[1].Entire,true)
and it would pick up the value at the time the trigger fires, but I get the following error

Code: Select all

Lua error:[string "echo("ItemBox", "\n----------------------------\n"....."]:2: 
')' expected (to close '(' at line 1) near 'name'
My head is going to explode!!!
Mapper of Bedlam

User avatar
Akaya
Posts: 414
Joined: Thu Apr 19, 2012 1:36 am

Re: echoLink iteration

Post by Akaya »

From the look of your error, you are missing the end ) on line 2 of the script in which you echo to ItemBox.
But I can't tell you much more without seeing the entire script that raises the error.

Silvine
Posts: 142
Joined: Sat Oct 23, 2010 2:36 pm

Re: echoLink iteration

Post by Silvine »

Whole script is

Code: Select all

itemSearch = matches[4]
resultsDB = {}
resultsDB = db:fetch(myitemDB.Item, db:like(myitemDB.Item.Name, "%"..itemSearch.."%"))
resultsWorn = resultsDB[1].Worn
resultsID = resultsDB[1].ID
resultsDB = db:fetch(myitemDB.Entire, db:eq(myitemDB.Entire.ID, resultsID))
if resultsWorn ~="" then 
cechoLink( "<pink> "..resultsWorn.."\n", [[echo("ItemBox", "\n----------------------------\n"..]]..resultsDB[1].Entire..[[)]],resultsDB[1].Entire,true)
end --if
The first bit adds the link as shown

and then clicking on it should send it to another window
Attachments
eqp2.PNG
eqp2.PNG (10.44 KiB) Viewed 5220 times
eqp.PNG
eqp.PNG (29.21 KiB) Viewed 5220 times
Mapper of Bedlam

Silvine
Posts: 142
Joined: Sat Oct 23, 2010 2:36 pm

Re: echoLink iteration

Post by Silvine »

It seems there is a problem with with echoing a multi line string. When I change resultsDB[1].Entire to resultsID it works ok. resultsID being a single word string and resultsDB[1].Entire being a multi line string. Any idea's?

Thanks

ps when using

Code: Select all

cechoLink("ItemBox", "<pink> "..resultsWorn.." "..itemSearch.."\n", [[echo(resultsID)]],resultsDB[1].Entire, true)
to send the link to another window it doesn't send as <pink> but stays with the default format. If i remove the "ItemBox" and send to the main window it is <pink> Bug maybe?
Mapper of Bedlam

Silvine
Posts: 142
Joined: Sat Oct 23, 2010 2:36 pm

Re: echoLink iteration

Post by Silvine »

I had another play with it, testing if \n breaks it.

Code: Select all

if resultsWorn ~="" then
resultsID = "hello there "
resultsID = resultsID.."its me again"

cechoLink("ItemBox", "<pink> "..resultsWorn.." "..itemSearch.."\n", [[echo("]]..resultsID..[[")]],resultsEntire, true)
cechoLink( "<pink> "..resultsWorn.."\n", [[echo("ItemBox", "]]..resultsID..[[")]],resultsEntire, true)
echo("ItemBox", "")
end --if
These both work, although echoing to another window is still default colours rather than <pink>
If I change the line

Code: Select all

resultsID = "hello there "
to

Code: Select all

resultsID = "hello there \n"
then I get the errors

Code: Select all

Lua error:[string "echo("ItemBox", "hello there ..."]:1: unfinished string near '"hello there '

and

Code: Select all

Lua error:[string "echo("hello there ..."]:1: unfinished string near '"hello there '
from the two links
Also after using cehcolink to another window it doesn't refresh so I had to force it adding the line

Code: Select all

echo("ItemBox", "")
The tip part works fine as shown in the screenshots, which is the info I want to ping of to another window when I click a link.
Do I just give up with it for the minute, or is there something can be done?

Thanks
Attachments
cechoworking.png
cechoNotworking.png
Mapper of Bedlam

Post Reply