Debugging Help Thread

Debugging Help Thread

Postby abraxsis » Mon Dec 01, 2014 1:29 am

I'm starting this thread for people like me who need help with triggers and scripts for mudlet.
Abraxsis

--------------------------------------------------------------------------------------------------------
This space for rent. Terms available upon request.
User avatar
abraxsis
 
Posts: 10
Joined: Tue Oct 28, 2014 11:09 pm
Location: The deepest darkest recesses of your nightmares
Status: Offline

Re: Debugging Help Thread

Postby abraxsis » Mon Dec 01, 2014 1:52 am

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?
Abraxsis

--------------------------------------------------------------------------------------------------------
This space for rent. Terms available upon request.
User avatar
abraxsis
 
Posts: 10
Joined: Tue Oct 28, 2014 11:09 pm
Location: The deepest darkest recesses of your nightmares
Status: Offline

Re: Debugging Help Thread

Postby *Breeze* » Mon Dec 01, 2014 4:22 am

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
User avatar
*Breeze*
Avatar Poster
 
Posts: 520
Joined: Mon Nov 05, 2007 9:24 am
Status: Offline

Re: Debugging Help Thread

Postby abraxsis » Mon Dec 01, 2014 4:30 am

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.
Abraxsis

--------------------------------------------------------------------------------------------------------
This space for rent. Terms available upon request.
User avatar
abraxsis
 
Posts: 10
Joined: Tue Oct 28, 2014 11:09 pm
Location: The deepest darkest recesses of your nightmares
Status: Offline

Re: Debugging Help Thread

Postby *Breeze* » Mon Dec 01, 2014 4:38 am

No problem
User avatar
*Breeze*
Avatar Poster
 
Posts: 520
Joined: Mon Nov 05, 2007 9:24 am
Status: Offline

Re: Debugging Help Thread

Postby *juggleblood* » Sat Dec 06, 2014 1:29 pm

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 /.
Talk to the clown.
User avatar
*juggleblood*
Hall of Fame Avatar Poster
 
Posts: 1304
Joined: Sun Jan 22, 2006 6:36 am
Location: Beyond Yonder
Status: Offline

Re: Debugging Help Thread

Postby *Breeze* » Sat Dec 06, 2014 1:34 pm

Thought it was \. not /.
User avatar
*Breeze*
Avatar Poster
 
Posts: 520
Joined: Mon Nov 05, 2007 9:24 am
Status: Offline


Return to Mudlet - unlimited possibilities

Who is online

Users browsing this forum: No registered users and 4 guests

cron