Register forum user name Search FAQ

Gammon Forum

Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the password reset link.

Due to spam on this forum, all posts now need moderator approval.

 Entire forum ➜ MUSHclient ➜ Lua ➜ Need help with converting trigger from jscript to Lua

Need help with converting trigger from jscript to Lua

It is now over 60 days since the last post. This thread is closed.     Refresh page


Posted by Verve   (2 posts)  Bio
Date Sun 29 Jul 2018 03:30 AM (UTC)

Amended on Sun 29 Jul 2018 05:13 AM (UTC) by Nick Gammon

Message
So, I feel like a dummy but I really can't figure this out on my own and I've been trying for days. A friend of mine gave me a script in jscript but I "script" (I mainly just patch together ghetto triggers) in Lua so I've been trying to convert this unsuccessfully.

This is for a fishing script on a MUD. The purpose is to detect the distance of the fishing line and, if it is out past 35 feet, to reel it in all the way and cast again and rinse and repeat until you get a desirable distance.


<trigger>
   enabled="y"
   group="Fishing"
   match="*You cast your hook into the * * feet from the *"
   send_to="12"
   sequence="100"
  <send>var distance = %3;
if (distance > 35) {
  DoAfter (1, 'reelin all');
  DoAfter (2, 'cast short');
}
else {
  send("reelin medium")
}</send>
</trigger>



Can anyone help me with this, pretty please?
Top

Posted by Nick Gammon   Australia  (23,133 posts)  Bio   Forum Administrator
Date Reply #1 on Sun 29 Jul 2018 05:17 AM (UTC)
Message
You haven't said what is wrong. If the trigger is not matching at all, please post (copy/paste) what the text from the MUD is.

If it is matching one problem I see is that the function is Send not send (it is case-sensitive).

Also, there is no "var" in Lua. And no braces in the way you used them.

This would be better:


distance = tonumber (%3)
if distance > 35 then
  DoAfter (1, 'reelin all')
  DoAfter (2, 'cast short')
else 
  Send("reelin medium")
end -- if

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Verve   (2 posts)  Bio
Date Reply #2 on Sun 29 Jul 2018 05:29 AM (UTC)
Message
Well, what's wrong is that it's in jscript and I need it in Lua! As the subject of this thread states, that's what I was asking for help with.

The trigger I posted was the original one given to me in jscript. I didn't write it. I didn't attempt to convert it for the purposes of this thread as I didn't want to embarrass myself by bungling it up.

Thanks for your help!
Top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


9,839 views.

It is now over 60 days since the last post. This thread is closed.     Refresh page

Go to topic:           Search the forum


[Go to top] top

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.