trigger with an unknown

mattness
Posts: 17
Joined: Sat May 19, 2012 8:34 pm

trigger with an unknown

Post by mattness »

So I'm trying to make a trigger with two unknowns(I've also tried it with one unknown). I want to kill a monster in the room. The monster is the unknown.

---
Example:

You are in the plains of Ishtar. This is an open area where the wind sweeps
across the plain and whips your clothing about you. The long bluegrass waves
about and rustles about your ankles tickling you as you walk.
Obvious exits: east, north, west, south
Two rabbits are here.
---

Pattern: ^(.*) (.*) (is|are) here\.$
Type: Perl Regex

Script: send("kill " .. matches[3])

I get no response. I have highlighting on too.

Also I don't understand the types. I havn't seen anything in the manuals for them either.
Last edited by mattness on Sun May 20, 2012 3:03 am, edited 1 time in total.

mattness
Posts: 17
Joined: Sat May 19, 2012 8:34 pm

Re: trigger with an unknown

Post by mattness »

Upon leaving the area I got a response:

You are at the entrance to Ishtar the land of newbies. The creatures
within are waiting to be slain by newbies. Have Fun.
Note: Type 'map' whenever you are lost
Obvious exits: north, east, west
A swirling portal and a newbie machine (Type 'pull handle') are here.
kill handle')
> No handle') here!

P.S. - I dont' know how to add the color to the post, which would be helpful.
Last edited by mattness on Sun May 20, 2012 2:43 am, edited 1 time in total.

mattness
Posts: 17
Joined: Sat May 19, 2012 8:34 pm

Re: trigger with an unknown

Post by mattness »

The Save button does wonders! Got it working. lol :oops:

mattness
Posts: 17
Joined: Sat May 19, 2012 8:34 pm

Re: trigger with an unknown

Post by mattness »

If there are more than one monster in the room it returns the plural version(naturally). How do I make it return the singular version?

Problem:
> You are in the forest of Ishtar. This forest is a massive stand of conifers.
Pine, spruce and hemlock stand tall and majestic all around you. A thick bed of
pine needles are on the ground and keep everything from growing.
Obvious exits: east, north, west, south
Two hares are here.
kill hares
The corpse of a hare is on the ground.
> the corpse of a hare is not a living thing!


Example:
Two hares are here.
kill hare

mattness
Posts: 17
Joined: Sat May 19, 2012 8:34 pm

Re: trigger with an unknown

Post by mattness »

I think what I need to do here is store the two unknowns as variables and if they match a pattern then send text.

Delrayne
Posts: 159
Joined: Tue Jun 07, 2011 7:07 pm
Contact:

Re: trigger with an unknown

Post by Delrayne »

What I did was just build a key/value table for all the targets I encounter.

Example:
Code: [show] | [select all] lua
Targets = {
["a brown rabbit"] = "rabbit",
["a blue rabbit"] = "rabbit",
["an angry dog"] = "dog",
["a rabid dog"] = "dog",
}
Then when I'm bashing, I check to see if if any of the mobs in the room match a mob in my table, if it does it sets my target variable to that mob's value in the table. So if I entered a room while bashing and saw a brown rabbit, my target would get set to rabbit.

Granted I have no idea if your mud supports gmcp and what items it stores with it if it does, but I pull room items from gmcp. Makes things like this way easier.

User avatar
chris
Posts: 493
Joined: Fri Jun 17, 2011 5:39 am

Re: trigger with an unknown

Post by chris »

You can reduce your patten to something like this:

^(.+) are here$

Then split matches[2] by spaces and select the last element which should be your mob. Then check the last letter for an s and try both variants.

mattness
Posts: 17
Joined: Sat May 19, 2012 8:34 pm

Re: trigger with an unknown

Post by mattness »

Both ideas are far above my skill level to code, but I like the table idea because when I travel across town or anything else I come in contact with my trigger activates. Not a good idea to kill the banker(or get killed by the banker more likely.)

What do I do with the variable Targets{}? And what is gmcp?

Delrayne
Posts: 159
Joined: Tue Jun 07, 2011 7:07 pm
Contact:

Re: trigger with an unknown

Post by Delrayne »

Code: [show] | [select all] lua
for k, v in pairs (Targets) do
  if k == matches[2] then
    target = v
    send("kill " .. target)
  end
end
Thats one thing you could do with the table

mattness
Posts: 17
Joined: Sat May 19, 2012 8:34 pm

Re: trigger with an unknown

Post by mattness »

What is k and v?

Post Reply