capturing a full string w/ wild cards

Posted by Silencher on Thu 26 Feb 2015 08:50 AM — 8 posts, 31,841 views.

#0
<triggers>
<trigger
group="TargetTrigger"
match="* attacks you *"
sequence="100"
>
<send>attacker = "%1"
SetVariable("Target", attacker)
testTarget = GetVariable("Target")
Note("Target is " .. testTarget)
</send>
</trigger>
</triggers>



Above is a trigger I have. The goal is to pull everything from the first * and store it into a string so I can use another alias to 'attack target'.

However, in the mud I'm playing, the info in that first * could range from a single name like 'Mike' to a short description, like 'a fluffy white poodle'.

I can't seem to get it to work. The alias I have is simple enough, and if I use a string, rather than 'testTarget', it fires correctly. The only thing I can think is that the first wildcard is not correctly being saved to the testTarget / Attacker variables.

Basically, this is just a way for me to quickly respond to aggressive mobs and/or PVP situations. Can anyone tell me what I'm missing?
USA #1
The problem is that your trigger is too greedy in what it captures. Short descriptions are, frankly, horrible for setting combat triggers against because they usually contain a bunch of extra 'fluff' that isn't a valid name for the mob you're fighting. Your fluffy white poodle for instance might have name keywords of dog and poodle but not fluffy or white and certainly won't have a as a recognized keyword. When your trigger attempts to feed 'a fluffy white poodle' as your target the server has no idea what you're talking about because you didn't give it a recognizable target.

If you intend to continue with this plan to respond to being attacked, you're going to need to build a database of descriptions and their corresponding keywords to feed your target variables or you're going to continue to run into issues with things like fluffy white poodles and lazy gate guards.
#2
The thing is my alias would be mostly just for PCs, but I need the trigger to work for everything. And right now it doesn't seem to take the string and insert it into the variable.
USA #3
If it works for any mobs, it's working for all of them. As I said before, the problem is that you're using the mob short descriptions rather than picking out functional keywords for your trigger. Players (probably) won't ever present such a problem because their only keyword should be their name. Also, if you're only trying to use this in response to aggressive mobs, you might be able to use mud aliases to get around even needing to pass names/ short descriptions to your alias at all.

Might be easier for us to verify with some actual output from your mud as well.
Amended on Fri 27 Feb 2015 04:13 AM by Meerclar
#4
There's a much easier way of doing this I believe. At the moment you have this:

Quote:


<triggers>
<trigger
group="TargetTrigger"
match="* attacks you *"
sequence="100"
>
<send>attacker = "%1"
SetVariable("TARGET", attacker)
testTarget = GetVariable("TARGET")
Note("Target is " .. testTarget)
</send>
</trigger>
</triggers>



And I think you need something like this:

Quote:


<triggers>
<trigger
group="TargetTrigger"
match="* attacks you *"
sequence="100"
>
SetVariable(target)
target = %1
Note("Target is : ", target)
</trigger>
</triggers>



In your example you have 2 variables doing the same thing: "TARGET" and "testtarget"

In my example it is simplified to one.. "target"

I could be wrong with this but it's my best shot, let us know how it goes :)
Amended on Fri 27 Feb 2015 11:12 AM by Lua_Newbie
Australia Forum Administrator #5
Silencher said:

I can't seem to get it to work. The alias I have is simple enough, and if I use a string, rather than 'testTarget', it fires correctly. The only thing I can think is that the first wildcard is not correctly being saved to the testTarget / Attacker variables.



What do you mean "if I use a string"? Can you post example output?
#6
I think you'll find that replacing

testTarget = GetVariable("TARGET")
with
testTarget = tostring(GetVariable("TARGET"))

will solve your problem here.

Without the tostring() the interpreter appears to that the value of the variable as another variable name, rather than a string. At least, that's been my experience so far.
Australia Forum Administrator #7
GetVariable always returns strings (or nil if the variable does not exist).