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 ➜ General ➜ Variable Question - AutoTargetting

Variable Question - AutoTargetting

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


Posted by Chade   (13 posts)  Bio
Date Thu 07 May 2009 03:12 PM (UTC)
Message
Hi,

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:

<triggers>
<trigger
expand_variables="y"
group="Chade"
ignore_case="y"
keep_evaluating="y"
match="^\&quot;(.+?)\d+\&quot;"
name="ihbash_"
regexp="y"
send_to="12"
sequence="100"
>
<send>if "%1" == "pony" then
display.Info("NO TARGETS HERE")
EnableTrigger("ihbash_", false)
else
Execute("t %1;bashon")
EnableTrigger("ihbash_", false)
end
</send>
</trigger>
</triggers>

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?

Cheers,

Chade
Top

Posted by Tboydston   (14 posts)  Bio
Date Reply #1 on Thu 07 May 2009 05:51 PM (UTC)
Message
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)
end

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

Posted by Chade   (13 posts)  Bio
Date Reply #2 on Thu 07 May 2009 06:20 PM (UTC)
Message
Thanks!

Encountering this problem now though:

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

Posted by Worstje   Netherlands  (899 posts)  Bio
Date Reply #3 on Thu 07 May 2009 07:35 PM (UTC)
Message
That language looks like Lua. Replace != by ~=, since != isn't valid in this language.
Top

Posted by Larkin   (278 posts)  Bio
Date Reply #4 on Fri 08 May 2009 11:33 AM (UTC)
Message
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.
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.


18,984 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.