Please help, been trying to figure this out for a few hours now :(

Posted by AaronM86 on Mon 29 Mar 2010 12:28 AM — 18 posts, 68,133 views.

#0
How can I get the following trigger to work??


<triggers>
<trigger
enabled="y"
expand_variables="y"
group="Basic - Support"
match="^(.*?) says \'(.*?) me\'$"
regexp="y"
send_to="12"
sequence="100"
>
<send>if "%1" == "self" then
world.send ("say Not going to happen")
elseif "%1" == "anythingotherthanthewordself" then
world.send ("cast %2 %1")
end</send>
</trigger>
</triggers>
USA #1
First: What's not working? It's hard to help you when we don't know what the symptoms are.

Second: it's world.Send, not world.send. Case matters.

Third: And... you can just use else instead of elseif "%1" == "something else" then.
Amended on Mon 29 Mar 2010 12:45 AM by Twisol
#2
Sorry for the quick post without explanation. I'm playing a MUD. I'm trying to make it so that if "Self" is seen as the sender of a say message, it will send say Not gonna happen.
But if anything other than the word "Self" is seen then it will cast on the sender of the say message if their message looks like this. Timmy says 'heal me' / I then send: cast heal timmy. I also want to have heal represented by %2 so I can send what spell they wish to be cast upon them. The reason I am trying to out Self is so that I cannot be tricked into casting damage spells onto myself.
USA #3
AaronM86 said:
Sorry for the quick post without explanation. I'm playing a MUD. I'm trying to make it so that if "Self" is seen as the sender of a say message, it will send say Not gonna happen. The reason I am trying to out Self is so that I cannot be tricked into casting damage spells onto myself.


Oh, yes, I understand that. My point is that you can do it much more simply.

Here's a version of the <send> script with my suggested changes (which you didn't say whether they worked or not):

if "%1" == "self" then
  world.Send("say Not going to happen")
else
  world.Send("cast %2 %1")
end
#4
Hrm, thank you for your help first off... I entered that in my trigger but for some reason now I can't even get the trigger to fire when it sees the appropriate message.
#5
Would using Jscript as my drop-down bar menu selection, under the Scripts sub-menu, for Scripting main-menu, pose any sort of problem as to why it's not firing at all now? I had a script file with jscript from a friend that I was using, does setting the trigger send to: Script conflict because it's written differently?
Australia Forum Administrator #6
I would use Lua unless you have a big reason not to.

As for the trigger, can you post the line (from the MUD) that you think it should match on, but doesn't?
USA #7
AaronM86 said:

Would using Jscript as my drop-down bar menu selection, under the Scripts sub-menu, for Scripting main-menu, pose any sort of problem as to why it's not firing at all now? I had a script file with jscript from a friend that I was using, does setting the trigger send to: Script conflict because it's written differently?


Yes, that code uses Lua, not JScript. You can't use two different scripting languages at once. The exception is when you have scripts in a plugin, because a plugin can run separately from the world and other plugins.

It might not keep the trigger from firing, but it would cause problems, certainly.
Amended on Mon 29 Mar 2010 04:45 AM by Twisol
#8
Okay this has gotten me further. First changed scripting to Lua, and trigger still wasn't firing. Disabled my chat_redirector plugin that was pulling my says to log in another world window. And now it is firing the new say trigger for this setup we're discussing; except it seems to be ignoring the ifcheck on the Self and still casting on me.
#9
The line I'm trying to fire off of is Trigger: * says '* me'

I also tried converting to regular expression, but I have the same problem occur, where it's now ignoring the ifcheck for Self and still casting on me.
USA #10
He meant the line on the MUD that you're trying to trigger on, not the pattern line you're using to do it. An example of real output from the MUD you're trying to respond to.
#11
Self the male Gryphon Cub says 'distort me'
USA #12
AaronM86 said:

Self the male Gryphon Cub says 'distort me'


Okay, I think this is your issue. This is your pattern:

^(.*?) says \'(.*?) me\'$

It will catch everything up to the "says" for capture 1. So %1 is "Self the male Grphon Cub". What I expect you really want is this:

^([^ ]+).*says '(.*?) me'$

That little voodoo there means "one or more of anything but a space". It'll capture up until the first space, which means it should capture "Self". I also have .* after it so that you can have stuff like suffixes and titles after the name - which you do have here - without actually capturing it.

The final issue I'm seeing is that "Self" is not the same as "self". Case matters! You should either check the "ignore case" checkbox for this trigger, or use this instead to compare:

if string.lower("%1") == "self" then


That'll return a lowercased version of the capture, which would be "self" in this case.
Amended on Mon 29 Mar 2010 06:18 AM by Twisol
#13
Excellent, the ignore case checkmark wouldn't work, still casted on me in that circumstance. But your string.lower check fixed everything. Thank you so much for your patience with me tonight; you have helped me to learn alot. I'm just a beginner with alot of these kinds of things. I've been learning from my friends jscript file that he put together for me by just copying his functions and what not and trying to piece together my own inventions from that lol. If I can get Lua to work through my triggers like this more efficiently then I'll surely do more research into that language. Again, I truly appreciate your help.
USA #14
Not a problem! I'm glad I could help. :)
#15
Another question popped into my mind lol, kind of pertains to this same subject. Is it possible to do 2 ifs in the same trigger? For instance:

if string.lower("%1") == "self" then
world.Send("say Not going to happen")
if string.lower("%1") == "terkal" then
world.Send("say Not going to happen")
else
world.Send("cast %2 %1")
end
Australia Forum Administrator #16
What language is this? Lua?

You can do it with elseif, eg.


if string.lower("%1") == "self" then
  Send ("say Not going to happen")
elseif string.lower("%1") == "terkal" then
  Send("say Not going to happen")
else
  Send("cast %2 %1")
end


If you have a lot of them, you could use a table, eg.


not_going_to = {
  self = true,
  terkal = true,
  nick = true,
  twisol = true,
-- add more here
  }

if not_going_to [string.lower ("%1")] then
  Send("say Not going to happen")
else
  Send("cast %2 %1")
end


That indexes into the table with the word converted to lower-case. If it matches you say "not going to happen". If not, you do it.
#17
Yes, Lua. :) And thank you both once again lol. I'm going to also store all of these set ups in an notepad so I can try to assemble these as best I can on my own in the future. I feel bad pestering with miniscule things lol, I do try to figure it out on my own before I post, just to let you know :) Regardless, thanks!