Issue With Clickable Links

Post Reply
EulersIdentity
Posts: 27
Joined: Fri Jun 26, 2015 8:52 am

Issue With Clickable Links

Post by EulersIdentity »

I'm trying to add clickable links to the "info here" output in Achaea that will allow me to do things like add the IDs of items in the room to a table. When I type "info here" I have something that looks like
Code: [show] | [select all] lua
shrine56335         a shrine of Babel
chef90088           Chef Cornelios
totem257612         a runic totem
Number of objects: 3
I made a trigger that matches ^(\D+)(\d+)\s+(\D.*)$ which has the associated script:
Code: [show] | [select all] lua
if ihFlag == true then
	ihDescription = matches[4]
	echo("   ")
	echoLink("add", [[addHuntTarg(ihDescription)]], "Add to hunting targets")
	echo("  ")
	echoLink("rem", [[remHuntTarg(ihDescription)]], "Remove from hunting targets")
end -- if
the ihFlag variable is just there to keep the pattern from matching at inappropriate times. Anyways, the links show up and work properly, except if I click one of them (either the add or remove buttons) it only pattern matches the last item in the room description. In this case, if I click any of the 'add' links, then it'll call the function addHuntTarg("a runic totem"). So what appears to be happening is that ihDescription is not sticking to the clickable link itself, but the link accesses the value of ihDescription at the time I click it. How do I get the desired behavior?


EDIT: I'm going to be accomplishing this particular task through GMCP, but I'd still love to hear the solution as I intend to write similar scripts in the near future that will have the same problem.

User avatar
Belgarath
Posts: 232
Joined: Fri Jul 26, 2013 7:19 am
Discord: macjabeth#7149

Re: Issue With Clickable Links

Post by Belgarath »

Try this instead:
Code: [show] | [select all] lua
if ihFlag == true then
  local ihDescription = matches[4]
  echo "   "
  echoLink("add", [[addHuntTarg("]] .. ihDescription .. [[")]], "Add to hunting targets")
  echo "  "
  echoLink("rem", [[remHuntTarg("]] .. ihDescription .. [[")]], "Remove from hunting targets")
end
Last edited by Belgarath on Fri Jul 17, 2015 9:02 am, edited 1 time in total.

EulersIdentity
Posts: 27
Joined: Fri Jun 26, 2015 8:52 am

Re: Issue With Clickable Links

Post by EulersIdentity »

That solution makes it so if I click the links absolutely nothing happens. It doesn't even send a message to the debugger.

User avatar
Belgarath
Posts: 232
Joined: Fri Jul 26, 2013 7:19 am
Discord: macjabeth#7149

Re: Issue With Clickable Links

Post by Belgarath »

Ah, I forgot to add the quotes! I edited the post with the correct method.

Post Reply