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.
 Entire forum ➜ MUSHclient ➜ Lua ➜ Not understanding what's wrong with my script

Not understanding what's wrong with my script

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


Posted by Dawastedpanda   (14 posts)  Bio
Date Tue 10 Mar 2020 09:35 PM (UTC)

Amended on Thu 12 Mar 2020 03:48 AM (UTC) by Nick Gammon

Message

168 : function toTarget(name, line, args)
169 : if args[1] ~= nil and args[1] ~= "" then
170 : mobTarget = args[1]
171*: elseif mobTarget = "none" then
172 : triggerOff()
173 : ColourNote ("yellow", "", "Sensing Target Cleared.")
174 : return
175 : end
Top

Posted by Dawastedpanda   (14 posts)  Bio
Date Reply #1 on Wed 11 Mar 2020 12:39 AM (UTC)

Amended on Thu 12 Mar 2020 03:48 AM (UTC) by Nick Gammon

Message

<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE muclient>
<!-- Saved on Sunday, March 08, 2020, 1:40 PM -->
<!-- MuClient version 4.94 -->

<muclient>
<plugin
   name="AutoSenseV4"
   author="Kaiza"
   id="6f28bac9aa18955b674c0d43"
   language="Lua"
   purpose="Automatically Sense Mobs"
   save_state="y"
   date_written="2020-03-10 13:39:17"
   requires="4.94"
   version="1.0"
   >

</plugin>


<!--  Get our standard constants -->

<include name="constants.lua"/>


<!--  Triggers  -->

<triggers>
<trigger name= "senseTarget" match= "You concentrate and sense their ki *" group= "sense" script= "trackTarget"   enabled= "y" regexp= "y" sequence= "100"/>
<trigger name= "atTarget"    match= "You're already in the same room!!"    group= "sense" script= "triggerOff" enabled= "y" regexp= "y" sequence= "100"/>
<trigger name= "cantSense"   match= "That mob does not exist, cannot *"    group= "sense" script= "triggerOff" enabled= "y" regexp= "y" sequence= "100"/>
</triggers>

<aliases>
<alias name= "trackTarget" match= "track *"  script= "toTarget" enabled= "y" regexp= "y" send_to="1" sequence= "100"/>
</aliases>
<script>
<![CDATA[

local mobTarget = ""

function triggerOn()
    EnableTriggerGroup ("sense", true)
end
function triggerOff()
    ColourNote ("yellow", "", "Sensing disabled.")
    EnableTriggerGroup ("sense", false)
end

function trackTarget()
    triggerOn()
    Send("sense ".. mobTarget)
end

function toTarget(name, line, args)
  if args[1] ~= nil and args[1] ~= "" then -- entered one mob to track
	mobTarget = args[1]
  elseif mobTarget = "none" then
    triggerOff()   -- disables the trigger if none is entered.
	ColourNote ("yellow", "", "Sensing Target Cleared.")
    return
  end
  trackTarget()
end
--[[ 
  <alias match="^track (.*?)?$" script="toTarget" enabled="y" ignore_case="y" regexp="y" sequence="100" />
  ]]--

]]>
</script>
</muclient>




That is my entire script. I want to be able to type track (mob) and it will automatically begin sensing the mob
Top

Posted by Fiendish   USA  (2,533 posts)  Bio   Global Moderator
Date Reply #2 on Wed 11 Mar 2020 03:59 AM (UTC)

Amended on Wed 11 Mar 2020 04:00 AM (UTC) by Fiendish

Message
Next time please include the error message as well. But I can say already that
elseif mobTarget = "none" then

needs to have == not =

https://github.com/fiendish/aardwolfclientpackage
Top

Posted by Dawastedpanda   (14 posts)  Bio
Date Reply #3 on Thu 12 Mar 2020 01:20 AM (UTC)
Message
Thank you, that fixed the problem I was having. It lead me to a new problem though.

When I type track (mobname) In game, it is not picking up the wild card and assigning it to mobTarget.

Any idea why?
Top

Posted by Nick Gammon   Australia  (23,120 posts)  Bio   Forum Administrator
Date Reply #4 on Thu 12 Mar 2020 03:57 AM (UTC)

Amended on Thu 12 Mar 2020 03:59 AM (UTC) by Nick Gammon

Message

<alias name= "trackTarget" match= "track *"  script= "toTarget" enabled= "y" regexp= "y" send_to="1" sequence= "100"/>


First, you have checked "regular expression" but it isn't really a regular expression. (It is, but it matches "track" followed by zero or more spaces, and you haven't assigned that to be a wildcard).

Either get rid of regexp= "y" or make the match text a regular expression, eg.


^track (.*)$


Second, you made "mobTarget" local which means its lifetime is not as long as you would like. Get rid of "local" before mobTarget.

(Actually, that might only apply to how I was testing it. Fix the regular expression first and see what happens).

- Nick Gammon

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

Posted by Dawastedpanda   (14 posts)  Bio
Date Reply #5 on Thu 12 Mar 2020 10:07 PM (UTC)
Message
Problem is completely fixed. Thank you. It runs fine now.
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.


14,856 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.