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

Gammon Forum

See www.mushclient.com/spam for dealing with forum spam. Please read the MUSHclient FAQ!

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  General
. . -> [Subject]  Variable Question - AutoTargetting
Home  |  Users  |  Search  |  FAQ
Register forum user name
Forgotten password?

Variable Question - AutoTargetting

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

Posted by Chade   (13 posts)  [Biography] bio
Date Thu 07 May 2009 03:12 PM (UTC)

Still quite new to coding in lua and MUSH itself, just wanted to see if I could get a bit of help with something. I'm trying to write a script which will automatically target things for me, but I want to write a few exceptions into the script. My current version looks a little like this:

<send>if "%1" == "pony" then
display.Info("NO TARGETS HERE")
EnableTrigger("ihbash_", false)
Execute("t %1;bashon")
EnableTrigger("ihbash_", false)

This works relatively well for my purposes but has a few problems and I want to make it work better.

This is a quick example of what the NPC/Item list looks like:

"gatekeeper42866" a hooded gatekeeper
"pony36065" a pale blue, sleek pony with feathered wings
Number of objects: 2

I own the pony which is why I don't want it targetted. In the above situation the script works fine, but if I enter the room and then an NPC follows me in I encounter problems, the pony becomes the first NPC on the list which prevents the auto-targetter working.

"pony36065" a pale blue, sleek pony with feathered wings
"gatekeeper42866" a hooded gatekeeper
Number of objects: 2

The final problem I have is when inanimate objects are on the list, as 9 times out of 10 they've always first on the list.

"seal47870" a circular seal
"gatekeeper42866" a hooded gatekeeper
"pony36065" a pale blue, sleek pony with feathered wings
Number of objects: 3

If I attempt to target and attack the seal, as it's an item I get one of three messages:

Ahh, I am truly sorry, but I do not see anyone by that name here.

You detect nothing here by that name.

Nothing can be seen here by that name.

Anyone have any suggestions as to what I could do to improve functionality?


[Go to top] top

Posted by Tboydston   (14 posts)  [Biography] bio
Date Reply #1 on Thu 07 May 2009 05:51 PM (UTC)
This isn't too terribly hard, I promise.

Here's the issue: When you encounter a pony, you disable the trigger that follows your INFO HERE (the command that prompts the list of items in a room, for those that don't do IRE games). Now, if it didn't do this, you'd always target the last name on the list. For example:

"MUSHUser0001" Nick Gammon
"MUSHUser1853" Thomas B
"MUSHUser0892" Worstje

Your trigger basically scans for things in quotes that end with number. Since it doesn't see a pony, that trigger will execute three times and end by targeting MUSHUser0892, who is Worstje. If MUSHUsr1853, Thomas B, was actually a pony, that is
"MUSHUSer0001" Nick Gammon
"Pony0022" Thomas B
"MUSHUser0892" Worstje
things would happen like this:
MUSH sees "MUSHUSer0001", it's not a pony, so we
Execute("t %1;bashon")
EnableTrigger("ihbash_", false)
, then it sees a pony. So, it does this:
display.Info("NO TARGETS HERE")
EnableTrigger("ihbash_", false)
Now that the ibash_ trigger is turned off, it won't be able to see Worstje. Problem!

Here's how to fix the pony issue. Change the entire <send> schtuff to:
if "%1" != "pony" then
Execute("t %1;bashon")
EnableTrigger("ihbash_", false)

We want the pony to be ignored, this will do that.
Now, you're still going to have the issue of your target always being the last item in the room since that'll be the last line in the IH.

If you really want to stop targeting inanimate objects completely you'll need either a list of animate objects or a list of inanimate objects to target/avoid. The script has no idea if the item can be targeted or not unless you code in a few things to look out for.
[Go to top] top

Posted by Chade   (13 posts)  [Biography] bio
Date Reply #2 on Thu 07 May 2009 06:20 PM (UTC)

Encountering this problem now though:

Compile error
World: Treant
Immediate execution
[string "Trigger: ihbash_"]:1: 'then' expected near '!'
[Go to top] top

Posted by Worstje   Netherlands  (899 posts)  [Biography] bio
Date Reply #3 on Thu 07 May 2009 07:35 PM (UTC)
That language looks like Lua. Replace != by ~=, since != isn't valid in this language.
[Go to top] top

Posted by Larkin   (278 posts)  [Biography] bio
Date Reply #4 on Fri 08 May 2009 11:33 AM (UTC)
I would suggest that what you really want to do is capture all the keywords (names) from INFO HERE, putting them into a list as you go. When you hit the Number of objects line, you scan that list against your priority list of valid targets you want to hunt. That way, if you walk into a room with a cave-fisher and a solifugid, you could prioritize attacking the cave-fisher first, since he's already aggressive.
[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.


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.


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 FutureQuest]