[Home] [Downloads] [Search] [Help/forum]


Register forum user name Search FAQ

Gammon Forum

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  Plugins
. . -> [Subject]  Aardwolf Campaign Mob Locator

Aardwolf Campaign Mob Locator

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


Posted by Csd132   (6 posts)  [Biography] bio
Date Tue 17 Feb 2009 01:56 AM (UTC)
Message
Basically, I'm trying to create a script that is able to help me pinpoint which mob (out of many with the same name) is my campaign mob and the room that the particular mob is located in.

To do this, I tried adapting the Aardwolf Autohunt Plugin to instead work with a campaign. The basic idea is to use the "hunt trick" to find your mob. This trick is basically typing hunt 1.<mob name>, hunt 2.<mob name>, etc. until I am told "You are unable to hunt that mob for some reason.". That mob (x.<mob name>) is the specific mob I need and I can then type where X.<mob name> to find out what room it is in.

Currently, I've been doing it manually, but in some areas, typing hunt 1...26.prince or guard or whatever gets extremely tedious. If I could automate it a bit, that would be a lot more helpful.

My attempts to modify the autohunt script have given me the following errors (and I don't know if I'm really on the right track anyway):

Line 151: Error parsing script (problem in this file)

What I have so far is in the next post. Please help me figure out how to fix it. I'm an extremely novice lua coder. Aside from changing a couple triggers and taking out a couple, the main changes I made were to cphunt and cphunthere functions. Thanks!


[Go to top] top

Posted by Csd132   (6 posts)  [Biography] bio
Date Reply #1 on Tue 17 Feb 2009 01:56 AM (UTC)

Amended on Tue 17 Feb 2009 09:34 PM (UTC) by Nick Gammon

Message

<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE muclient>
<!-- Saved on Wednesday, July 26, 2006, 11:18 AM -->
<!-- MuClient version 3.74 -->

<!-- Plugin "Aardwolf_cphunterLUA" generated by Plugin Wizard -->

<muclient>
<plugin
   name="Aardwolf_cphunterLUA"
   author="Onoitsu2"
   id="e5ba9d8d543592b7ae80926b"
   language="Lua"
   purpose="This will locate your cp mob's room."
   date_written="2006-07-26 11:15:29"
   requires="3.74"
   version="1.1"
   >
<description trim="n">
<![CDATA[
Aardwolf_cphunterLUA Help File
cphunt MOBNAME          - Turns on cphunting of MOBNAME
cphunt off              - Turns off cphunting
cphunt delay #          - Sets the Delay in seconds between hunt movements (single digit 1-9, Default 3)
cphunt help             - Displays this help file

]]>
</description>

</plugin>


<!--  Get our standard constants -->

<include name="constants.lua"/>

<!--  Triggers  -->

<triggers>
  <trigger
   enabled="n"
   group="cphunter"
   match="^You have no idea what you\'re doing\, but maybe (.*?) left (.*?)\?$"
   name="cphunter1"
   regexp="y"
   script="cphunt"
   send_to="12"
   sequence="100"
  >
  </trigger>
  <trigger
   enabled="n"
   group="cphunter"
   match="^The trail of (.*?) is confusing\, but you\'re reasonably sure (?:.*?) headed (.*?)\.$"
   name="cphunter2"
   regexp="y"
   script="cphunt"
   send_to="12"
   sequence="100"
  >
  </trigger>
  <trigger
   enabled="n"
   group="cphunter"
   match="^You are confident that (.*?) passed through here\, heading (.*?)\.$"
   name="cphunter3"
   regexp="y"
   script="cphunt"
   send_to="12"
   sequence="100"
  >
  </trigger>
  <trigger
   enabled="n"
   group="cphunter"
   match="^There are traces of (.*?) having been here\. Perhaps they lead (.*?)\?$"
   name="cphunter4"
   regexp="y"
   script="cphunt"
   send_to="12"
   sequence="100"
  >
  </trigger>
  <trigger
   enabled="n"
   group="cphunter"
   match="^You are almost certain that (.*?) is (.*?) from here\.$"
   name="cphunter5"
   regexp="y"
   script="cphunt"
   send_to="12"
   sequence="100"
  >
  </trigger>
  
 <trigger
   group="cphunter"
   match="You seem unable to hunt that target for some reason\.$"
   regexp="y"
   script="cphunthere"
   send_to="12"
   sequence="100"
   sound="C:\windows\media\tada.wav"
   sound_if_inactive="y"
  >
  </trigger>

  <trigger
   enabled="n"
   group="cphunter"
   match="^(You see no (.*) here\.|No way\! You are still fighting\!|No\-one in this area by that name\.)$"
   regexp="y"
   script="cphuntstop"
   send_to="12"
   sequence="100"
  >
  </trigger>
</triggers>

<!--  Aliases  -->

<aliases>
  <alias
   name="cphunter_alias"
   match="^cphunt (off|help|delay ((?:\d+)?\.?\d+)|(.*?))$"
   enabled="y"
   expand_variables="y"
   regexp="y"
   script="cphuntalias"
   send_to="12"
   ignore_case="y"
   sequence="100"
  >
  </alias>
  <alias
   name="cphunter_alias2"
   match="^ah (off|help|delay ((?:\d+)?\.?\d+)|(.*?))$"
   enabled="y"
   expand_variables="y"
   regexp="y"
   script="cphuntalias"
   send_to="12"
   ignore_case="y"
   sequence="100"
  >
  </alias>
</aliases>

<!--  Plugin help  -->

<script>
<![CDATA[
huntdelay = GetVariable("huntdelay")
if huntdelay == nil or huntdelay == "" then
huntdelay = 3
SetVariable("huntdelay",3)
ColourNote("white","green","cphunter Delay, Set to Default: ","yellow","green","3")
end -- if

direction = none

function cphuntalias(sName,sLine,wildcards)
if string.lower(wildcards[1]) == "off" then
ColourNote("white", "red", "cphunter OFF")
EnableTriggerGroup("cphunter",false)
elseif string.lower(wildcards[1]) == "help" then
OnHelp()
elseif string.find(string.lower(wildcards[1]),"delay ",1,true) then
if tonumber(wildcards[2]) < 0.5 or wildcards[2] == "" then
ColourNote("white","red","cphunter Delay Invalid, Setting to Default: ","yellow","red","3")
SetVariable("huntdelay",3)
SaveState()
else
ColourNote("white","green","cphunter Delay set to: ","yellow","green",tonumber(wildcards[2]))
SetVariable("huntdelay",tonumber(wildcards[2]))
SaveState()
end -- if
else
Send("hunt " .. string.lower(wildcards[1]))
ColourNote("white", "green", "cphunter ON! (Hunting " .. wildcards[1] .. ")")
SetVariable("cphuntmob",string.lower(wildcards[1]))
EnableTriggerGroup("cphunter",true)
end
end -- cphuntalias

function cphunt(sName,sLine,wildcards)
if GetVariable("mobnum") == nil or GetVariable("mobnum") == "" then
SetVariable("mobnum",1)
if GetVariable("finnum") == nil or GetVariable("finnum") == "" then
SetVariable("finnum","mobnum")
mobname = string.lower(wildcards[2])
Send(hunt " .. GetVariable("mobnum").GetVariable("mobname"))
DoAfterSpecial(tonumber(GetVariable("huntdelay")),'Send("hunt " .. GetVariable("cphuntmob"))',12)
SetVariable("mobnum", "tonumber(GetVariable("mobnum"))+1)
end -- cphunt

function cphunthere(sName,sLine,wildcards)
GetVariable("finnum")
GetVariable("mobname")
send(where " .. GetVariable("finnum").GetVariable("mobname"))
ColourNote("white", "green", "Your CP mob was located!")
EnableTriggerGroup("cphunter",false)
end -- cphunthere

function cphuntstop(sName,sLine,wildcards)
ColourNote("white", "red", "cphunter OFF")
EnableTriggerGroup("cphunter",false)
end -- cphunthere

function OnPluginInstall()
OnHelp()
end -- OnPluginInstall

function OnHelp ()
  Note(GetPluginInfo(GetPluginID(),3))
end
]]>
</script> 

</muclient>
[Go to top] top

Posted by Artel   USA  (65 posts)  [Biography] bio
Date Reply #2 on Tue 17 Feb 2009 02:29 PM (UTC)
Message
You should also get an error like this:
Compile error
Plugin: Aardwolf_cphunterLUA (called from world: Aardwolf)
Immediate execution
[string "Plugin"]:193: ')' expected near 'mobnum'
Error context in script:
 189 : SetVariable("mobnum",1)
 190 : if GetVariable("finnum") == nil or GetVariable("finnum") == "" then
 191 : SetVariable("finnum","mobnum")
 192 : mobname = string.lower(wildcards[2])
 193*: Send(hunt " .. GetVariable("mobnum").GetVariable("mobname"))
 194 : DoAfterSpecial(tonumber(GetVariable("huntdelay")),'Send("hunt " .. GetVariable("cphuntmob"))',12)
 195 : SetVariable("mobnum", "tonumber(GetVariable("mobnum"))+1)
 196 : end -- cphunt
 197 : 


It looks as if the period in Send(hunt " .. GetVariable("mobnum").GetVariable("mobname")) needs to be concatenated as a string. So it should probably be Send(hunt " .. GetVariable("mobnum").."."..GetVariable("mobname"))

Artel.
[Go to top] top

Posted by Nick Gammon   Australia  (22,973 posts)  [Biography] bio   Forum Administrator
Date Reply #3 on Tue 17 Feb 2009 09:39 PM (UTC)
Message
I edited your post to add the [code] tags to make the code more readable. Unfortunately that didn't help a great amount. You make things *much* easier for yourself if you indent code so you can read it better. For example, instead of:


function cphuntalias(sName,sLine,wildcards)
if string.lower(wildcards[1]) == "off" then
ColourNote("white", "red", "cphunter OFF")
EnableTriggerGroup("cphunter",false)
elseif string.lower(wildcards[1]) == "help" then
OnHelp()
elseif string.find(string.lower(wildcards[1]),"delay ",1,true) then
if tonumber(wildcards[2]) < 0.5 or wildcards[2] == "" then
ColourNote("white","red","cphunter Delay Invalid, Setting to Default: ","yellow","red","3")
SetVariable("huntdelay",3)
SaveState()
else
ColourNote("white","green","cphunter Delay set to: ","yellow","green",tonumber(wildcards[2]))
SetVariable("huntdelay",tonumber(wildcards[2]))
SaveState()
end -- if
else
Send("hunt " .. string.lower(wildcards[1]))
ColourNote("white", "green", "cphunter ON! (Hunting " .. wildcards[1] .. ")")
SetVariable("cphuntmob",string.lower(wildcards[1]))
EnableTriggerGroup("cphunter",true)
end
end -- cphuntalias


Try:


function cphuntalias(sName,sLine,wildcards)
  if string.lower(wildcards[1]) == "off" then
    ColourNote("white", "red", "cphunter OFF")
    EnableTriggerGroup("cphunter",false)
  elseif string.lower(wildcards[1]) == "help" then
    OnHelp()
  elseif string.find(string.lower(wildcards[1]),"delay ",1,true) then
    if tonumber(wildcards[2]) < 0.5 or wildcards[2] == "" then
      ColourNote("white","red","cphunter Delay Invalid, Setting to Default: ","yellow","red","3")
      SetVariable("huntdelay",3)
      SaveState()
    else
      ColourNote("white","green","cphunter Delay set to: ","yellow","green",tonumber(wildcards[2]))
      SetVariable("huntdelay",tonumber(wildcards[2]))
      SaveState()
    end -- if
  else
    Send("hunt " .. string.lower(wildcards[1]))
    ColourNote("white", "green", "cphunter ON! (Hunting " .. wildcards[1] .. ")")
    SetVariable("cphuntmob",string.lower(wildcards[1]))
    EnableTriggerGroup("cphunter",true)
  end
end -- cphuntalias


Each time you use an "if" go in a couple of spaces, and when you get the "else" or "end" go back out. That makes the logic much easier to see.


- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Nick Gammon   Australia  (22,973 posts)  [Biography] bio   Forum Administrator
Date Reply #4 on Tue 17 Feb 2009 09:40 PM (UTC)
Message
Doing that to your cphunt function immediately reveals some missing ends:


function cphunt(sName,sLine,wildcards)
  if GetVariable("mobnum") == nil or GetVariable("mobnum") == "" then
    SetVariable("mobnum",1)
    
  if GetVariable("finnum") == nil or GetVariable("finnum") == "" then
    SetVariable("finnum","mobnum")
    
  mobname = string.lower(wildcards[2])
  Send(hunt " .. GetVariable("mobnum").GetVariable("mobname"))
  DoAfterSpecial(tonumber(GetVariable("huntdelay")),'Send("hunt " .. GetVariable("cphuntmob"))',12)
  SetVariable("mobnum", "tonumber(GetVariable("mobnum"))+1)
end -- cphunt


Neither of the first two ifs have an end associated with them, so this will never compile.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Nick Gammon   Australia  (22,973 posts)  [Biography] bio   Forum Administrator
Date Reply #5 on Tue 17 Feb 2009 09:41 PM (UTC)
Message
Quote:

So it should probably be Send(hunt " .. GetVariable("mobnum").."."..GetVariable("mobname"))


I agree with you there.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Csd132   (6 posts)  [Biography] bio
Date Reply #6 on Wed 18 Feb 2009 11:17 PM (UTC)

Amended on Wed 18 Feb 2009 11:38 PM (UTC) by Nick Gammon

Message
Thanks Nick and Artel! I fixed those errors as well as a couple others and now it seems to work.


<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE muclient>
<!-- Saved on Wednesday, July 26, 2006, 11:18 AM -->
<!-- MuClient version 3.74 -->

<!-- Plugin "Aardwolf_cphunterLUA" generated by Plugin Wizard -->

<muclient>
<plugin
   name="Aardwolf_cphunterLUA"
   author="Anatema"
   id="e5ba9d8d543592b7ae80926b"
   language="Lua"
   purpose="This will locate your cp mob's room."
   date_written="2006-07-26 11:15:29"
   requires="3.74"
   version="1.1"
   >
<description trim="n">
<![CDATA[
Aardwolf_cphunterLUA Help File
cphunt MOBNAME          - Turns on cphunting of MOBNAME
cphunt off              - Turns off cphunting
cphunt delay #          - Sets the Delay in seconds between hunt movements (single digit 1-9, Default 3)
cphunt help             - Displays this help file

]]>
</description>

</plugin>


<!--  Get our standard constants -->

<include name="constants.lua"/>

<!--  Triggers  -->

<triggers>
  <trigger
   enabled="n"
   group="cphunter"
   match="^You have no idea what you\'re doing\, but maybe (.*?) left (.*?)\?$"
   name="cphunter1"
   regexp="y"
   script="cphunt"
   send_to="12"
   sequence="100"
  >
  </trigger>
  <trigger
   enabled="n"
   group="cphunter"
   match="^The trail of (.*?) is confusing\, but you\'re reasonably sure (?:.*?) headed (.*?)\.$"
   name="cphunter2"
   regexp="y"
   script="cphunt"
   send_to="12"
   sequence="100"
  >
  </trigger>
  <trigger
   enabled="n"
   group="cphunter"
   match="^You are confident that (.*?) passed through here\, heading (.*?)\.$"
   name="cphunter3"
   regexp="y"
   script="cphunt"
   send_to="12"
   sequence="100"
  >
  </trigger>
  <trigger
   enabled="n"
   group="cphunter"
   match="^There are traces of (.*?) having been here\. Perhaps they lead (.*?)\?$"
   name="cphunter4"
   regexp="y"
   script="cphunt"
   send_to="12"
   sequence="100"
  >
  </trigger>
  <trigger
   enabled="n"
   group="cphunter"
   match="^You are almost certain that (.*?) is (.*?) from here\.$"
   name="cphunter5"
   regexp="y"
   script="cphunt"
   send_to="12"
   sequence="100"
  >
  </trigger>
  
 <trigger
   group="cphunter"
   match="You seem unable to hunt that target for some reason\.$"
   regexp="y"
   script="cphunthere"
   send_to="12"
   sequence="100"
   sound="C:\windows\media\tada.wav"
   sound_if_inactive="y"
  >
  </trigger>

  <trigger
   enabled="n"
   group="cphunter"
   match="^(You see no (.*) here\.|No way\! You are still fighting\!|No\-one in this area by that name\.)$"
   regexp="y"
   script="cphuntstop"
   send_to="12"
   sequence="100"
  >
  </trigger>
</triggers>

<!--  Aliases  -->

<aliases>
  <alias
   name="cphunter_alias"
   match="^cphunt (off|help|delay ((?:\d+)?\.?\d+)|(.*?))$"
   enabled="y"
   expand_variables="y"
   regexp="y"
   script="cphuntalias"
   send_to="12"
   ignore_case="y"
   sequence="100"
  >
  </alias>
  <alias
   name="cphunter_alias2"
   match="^ah (off|help|delay ((?:\d+)?\.?\d+)|(.*?))$"
   enabled="y"
   expand_variables="y"
   regexp="y"
   script="cphuntalias"
   send_to="12"
   ignore_case="y"
   sequence="100"
  >
  </alias>
</aliases>

<!--  Plugin help  -->

<script>
<![CDATA[
huntdelay = GetVariable("huntdelay")
if huntdelay == nil or huntdelay == "" then
	huntdelay = 3
	SetVariable("huntdelay", 3)
	ColourNote("white","green","cphunter Delay, Set to Default: ","yellow","green","3")
end -- if

direction = none

function cphuntalias(sName,sLine,wildcards)
	if string.lower(wildcards[1]) == "off" then
		ColourNote("white", "red", "cphunter OFF")
		EnableTriggerGroup("cphunter",false)
	elseif string.lower(wildcards[1]) == "help" then
		OnHelp()
	elseif string.find(string.lower(wildcards[1]),"delay ",1,true) then
		if tonumber(wildcards[2]) < 0.5 or wildcards[2] == "" then
			ColourNote("white","red","cphunter Delay Invalid, Setting to Default: ","yellow","red","3")
			SetVariable("huntdelay",3)
			SaveState()
		else
			ColourNote("white","green","cphunter Delay set to: ","yellow","green",tonumber(wildcards[2]))
			SetVariable("huntdelay",tonumber(wildcards[2]))
			SaveState()
		end -- if
	else
		Send("hunt " .. string.lower(wildcards[1]))
		ColourNote("white", "green", "cphunter ON! (Hunting " .. wildcards[1] .. ")")
		SetVariable("cphuntmob",string.lower(wildcards[1]))
		EnableTriggerGroup("cphunter",true)
	end
end -- cphuntalias

function cphunt(sName,sLine,wildcards)
	if GetVariable("mobnum") == nil or GetVariable("mobnum") == "" then
		SetVariable("mobnum",1)
	end -- if
	DoAfterSpecial(tonumber(GetVariable("huntdelay")),'Send("hunt " .. GetVariable("mobnum").."."..GetVariable("cphuntmob"))',12)
	SetVariable("mobnum", tonumber(GetVariable("mobnum"))+1)
end -- cphunt

function cphunthere(sName,sLine,wildcards)	
	if GetVariable("mobnum") == nil or GetVariable("mobnum") == "" then
		Send("where " ..GetVariable("cphuntmob"))
	elseif tonumber(GetVariable("mobnum")) == 1 then
		Send("where " .. GetVariable("mobnum").. "."..GetVariable("cphuntmob"))
	else
	    --SetVariable("mobnum", tonumber(GetVariable("mobnum"))-1)
    	SetVariable("mobnum", tonumber(GetVariable("mobnum")))
		Send("where " .. GetVariable("mobnum").. "."..GetVariable("cphuntmob"))
	end -- if

	ColourNote("white", "green", "Your CP mob was located!")
	SetVariable("mobnum",1)
	EnableTriggerGroup("cphunter",false)
end -- cphunthere

function cphuntstop(sName,sLine,wildcards)
	ColourNote("white", "red", "cphunter OFF")
	SetVariable("mobnum",1)
	EnableTriggerGroup("cphunter",false)
end -- cphunthere

function OnPluginInstall()
OnHelp()
end -- OnPluginInstall

function OnHelp ()
  Note(GetPluginInfo(GetPluginID(),3))
end
]]>
</script> 

</muclient>


[Go to top] top

Posted by Csd132   (6 posts)  [Biography] bio
Date Reply #7 on Wed 18 Feb 2009 11:20 PM (UTC)
Message
Bah...I even indented it like you suggested it (and it was a lot easier to debug), but the formatting didn't transfer properly.

Aside from the missing end statements and the string concatenation issues, I fixed a couple missing double quotes and some logic errors. It's probably not the most efficient code and can easily be improved upon, but it does what I was looking for.

The plugin can be used both for cpmobs (as I intended) and also global quest mobs to help you narrow down what room the right mob is in. Thanks everyone for your help.
[Go to top] top

Posted by David Haley   USA  (3,881 posts)  [Biography] bio
Date Reply #8 on Wed 18 Feb 2009 11:22 PM (UTC)
Message
I've taken the liberty of adding code tags to your post since it looks like it's what you wanted. My apologies if you didn't mean to :-)

David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone

http://david.the-haleys.org
[Go to top] top

Posted by Nick Gammon   Australia  (22,973 posts)  [Biography] bio   Forum Administrator
Date Reply #9 on Wed 18 Feb 2009 11:39 PM (UTC)
Message
And I did a "convert forum codes" on it - this stops things like [i] turning your post into italics.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] 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.


30,043 views.

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

Go to topic:           Search the forum


[Go to top] top

Quick links: MUSHclient. MUSHclient help. Forum shortcuts. Posting templates. Lua modules. Lua documentation.

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

[Home]


Written by Nick Gammon - 5K   profile for Nick Gammon on Stack Exchange, a network of free, community-driven Q&A sites   Marriage equality

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( https://gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Hosted at HostDash]