Page 1 of 1

Issue With Clickable Links

Posted: Thu Jul 16, 2015 10:01 pm
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.

Re: Issue With Clickable Links

Posted: Fri Jul 17, 2015 6:32 am
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

Re: Issue With Clickable Links

Posted: Fri Jul 17, 2015 8:10 am
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.

Re: Issue With Clickable Links

Posted: Fri Jul 17, 2015 9:01 am
by Belgarath
Ah, I forgot to add the quotes! I edited the post with the correct method.