Page 1 of 1

Debugging Help Thread

PostPosted: Mon Dec 01, 2014 1:29 am
by abraxsis
I'm starting this thread for people like me who need help with triggers and scripts for mudlet.

Re: Debugging Help Thread

PostPosted: Mon Dec 01, 2014 1:52 am
by abraxsis
Ok, I'm trying to set up a trigger named Ticket to set my destination when I buy a boat ticket. Eventually I will have an entry for all the boat trips, but this is what I have so far:

trigger statement -
Code: Select all
^You now have a (.*) boat ticket.$
(pearl regex)

this is the script i have when the trigger fires

Code: Select all
------- bh ah -------
if matches [2] == "blue"
   then shipto = "bhah"
   end
end
------- bh ss --------
if matches[2] == "silver"
   then shipto = "bhss"
   end
end
-------- ss ah -------
if matches[2] == "black"
   then shipto = "ssah"
   end
end


I'm getting the following error: Trying to activate trigger Ticket failed, reason: Lua syntax error:[string "function Trigger17(}..."]:11: "expected near 'end'.

Any ideas/suggestions?

Re: Debugging Help Thread

PostPosted: Mon Dec 01, 2014 4:22 am
by *Breeze*
Without looking at my stuff on the laptop since it's not here atm, try removing the second end

If x == "y" then
z = "blah"
end

Re: Debugging Help Thread

PostPosted: Mon Dec 01, 2014 4:30 am
by abraxsis
Thanks, that got it. Looked back at the trigger I got the idea from and realized it had a second if-then nested inside the first, hence the need for 2 end statements. It just didn't click when I was first setting this up.

Re: Debugging Help Thread

PostPosted: Mon Dec 01, 2014 4:38 am
by *Breeze*
No problem

Re: Debugging Help Thread

PostPosted: Sat Dec 06, 2014 1:29 pm
by *juggleblood*
You may want to get in the habit of using elseif instead of having multiple ends. For example:

if matches[2]=="x" then x()
elseif matches[2]=="y" then y()
elseif matches[2]=="z" then z()
end

It's just a lil cleaner.

One other thing to note is that the . in your regex pattern means any single character. It's not of consequence in this example, just pointing it out to you for your info. If you want to indicate an actual period, use /.

Re: Debugging Help Thread

PostPosted: Sat Dec 06, 2014 1:34 pm
by *Breeze*
Thought it was \. not /.