mudlet saying trigger

I'm having trouble with a say trigger. I'd like quest givers to put out text I can click on to respond to their prompts, instead of having to copy/paste the text to respond.

I have this:

local saying = matches[3]
selectString(saying, 1)
replace("")
--echo("matched")
--echo(saying)
resetFormat()
setBold(true)
setUnderline(true)
fg("white")
echoLink(saying, [[send("say "..saying)]], "click to say", true)

but when I get yes/no prompts from quest givers, both links cause me to give the 'no' response. That saying variable seems to be overwriting on the second item.

My question is, how to I make each link use a fresh variable so that I can click yes?

Comments

  • The code is executed when you click the link, not when the link is generated, so any variables referenced will use the value at the time it's clicked. If that value changes after the link is echoed then it will use the wrong value; that seems to be what's happening here.

    You don't want the code to be send("say " .. saying) when the link is clicked. You want the code to be send("say Yes") or send("say No"). To do that: [[send("say ]] .. saying .. [[")]]. That creates a string with the value of saying when the trigger runs (i.e. either send("say Yes") or send("say No")) rather than using the variable later.
  • Brilliant, I was googling like mad trying to figure out how to get a value instead of a reference and that bracket notation wasn't coming up. It worked, thank you

Sign In or Register to comment.