General question & advice on specific issue

Post Reply
Skylark
Posts: 46
Joined: Mon Feb 22, 2010 12:38 am

General question & advice on specific issue

Post by Skylark »

I decided to write a small script to make purchasing items from ships in Achaea a little easier. When you enter the 'wares' command, you're presented with a list like this:
vial1357 an elixir of mana (oaken vial) 10 600gp
vial3783 an oaken vial 884 300gp
vial3874 a salve of mending (black-walnut vial) 7 1400gp
vial14572 an epidermal salve (oaken vial) 8 1100gp
...except aligned prettily. Whatever, not the point. I wanted to make it so that when you click on the the item it will do a series of things, like probe it for more information, give you options to purchase, etc. The way I have it set up now is that a trigger fires upon receiving the item line and changes the name of the item (for example, in the quote above, the name of the item in the first line would be 'vial1357') into a link that runs a function I define elsewhere.

As you can see, this trigger would fire many times upon checking the wares of a shop. I want the function to be able to do different things specific to the item clicked. Weaponprobe a weapon, pricecheck an herb, etc. The issue here is that I have to be able to pass information from the matches table of the trigger as arguments in the function called when the user clicks on the item name. However when the trigger uses setLink( [[function(argument), "tooltip"]]), if the argument is a variable, it will only be evaluated when the link is clicked, as opposed to when the trigger fires. There are a few ways I could try and implement this, but none of them get around the problem I stated in the previous sentence.

If there's some sort of notational way to resolve this it'd be simplest, but I don't know it. If not, I'm open to any suggestions of how to implement this. If anyone needs the code I've written to get a sense of what I"m doing I'll stick it up in a response. Thanks to anyone who took the time to wade through this.

Edit: Seems dense. To clarify, I get a bunch of lines like those above. I'm trying to turn the text at the beginning of those lines (ex: vial1357) into links with the setLink command. When clicked, I want to enter commands that depend upon the name of the item (ex: p vial1357).

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

Re: General question & advice on specific issue

Post by Vadi »

Embed the id in link code, like: [[function("]]..id..[[")]]

Skylark
Posts: 46
Joined: Mon Feb 22, 2010 12:38 am

Re: General question & advice on specific issue

Post by Skylark »

Thanks. I'd tried that but like : [[function(]] ..id.. [[)]] instead, never would have figured out the quotes.

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

Re: General question & advice on specific issue

Post by Vadi »

Well they're optional if you're only using the id as a number.

Post Reply