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 ➜ Priorities

Priorities

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


Posted by TruckDriver22   Denmark  (22 posts)  Bio
Date Wed 14 Jan 2009 03:31 AM (UTC)
Message
Ok this is my first post on this web site. I am more less a novice at this whole thing scripting and writing triggers but... I have gotta kinda far without any help.

I have made a trigger that heals group members when there low hp. the Problem is if multable people need heals it will spam me and try to heal all of them.

Mark happoneds to be the tank and will die next round if he gets to awful. Bob however will be fine if he is left unhealed untill another round.

what i want is my trigger to heal all of them but one each time the it comes up. and heal mark first if more then one of them needs heals.

exp..

Bob Awful
c 'heal' bob<----
John good
Tedd Fair
Mark Awful
c 'heal' bob<----



This is what i see

type Group

-----------------------------------------------------------------------------
Bob perfect rested standing
Mark perfect rested standing

the basic trigger is (Bob|Mark) awful
c 'heal' %1

(so basicly i wanna know how to make a trigger only go off one time in this senario. and i want it to pick mark over bob if they both need heals)

I dont know how i would make it match with someone in perfect, and someone in awful either.

I would be very greatful for some feed back. Big fan of mush client.!!!


Click bang... GAME OVER!
Top

Posted by TruckDriver22   Denmark  (22 posts)  Bio
Date Reply #1 on Wed 14 Jan 2009 03:28 PM (UTC)
Message
--------------------------------------------------------
Bob awful
Mark awful
c 'heal' mark

thats what i want to happon

Click bang... GAME OVER!
Top

Posted by Nick Gammon   Australia  (23,158 posts)  Bio   Forum Administrator
Date Reply #2 on Wed 14 Jan 2009 08:28 PM (UTC)
Message
You basically need to store their conditions (eg in a Lua table) and then scan the table to work out which one to cure next.

- Nick Gammon

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

Posted by TruckDriver22   Denmark  (22 posts)  Bio
Date Reply #3 on Thu 15 Jan 2009 02:05 AM (UTC)

Amended on Thu 15 Jan 2009 02:41 AM (UTC) by TruckDriver22

Message
thanks a lot for pointing me in the right direction. but is there an example of a table somewhere i cant seem to find any. i searched for lue tables. but i dont think what i found really helped me.

Click bang... GAME OVER!
Top

Posted by Mstevem   (3 posts)  Bio
Date Reply #4 on Fri 16 Jan 2009 01:07 AM (UTC)
Message
Interesting. I've been having trouble with this too. So by putting each set of information in the table, will all table information be read as one chunk of information, and could triggers set in sequence be used to set priority? Or is priority determined by the table itself?

Truckdriver, I found a few examples of tables searching for things like "heal script and "auto cleric". What I didn't see was how mushclient views the table upon looking at the tabled information (or if it does - I haven't gotten it to work properly so I'm not quite sure as of yet). Is it just as simple as setting a table and then the supporting triggers should work in an assigned order of priority?
Top

Posted by Nick Gammon   Australia  (23,158 posts)  Bio   Forum Administrator
Date Reply #5 on Fri 16 Jan 2009 04:32 AM (UTC)

Amended on Fri 16 Jan 2009 04:34 AM (UTC) by Nick Gammon

Message
First thing I would need to know is how many are in the group. For example, if you type "Group" how do I know when the list of group members is over? (or indeed, when it starts?).

You also need a way of letting the script know who is the tank, so it can prioritize based on who needs healing more urgently, if more than one reports "awful".

Does the group vary a lot, or do you usually have fixed names? With fixed names, a simple trigger like:


Match: ^(Bob|Mark) (Awful|Good|Fair)$


... may work (make sure you get the capitalization right).

The trigger could then do something like set the status in a table, like this:


<triggers>
  <trigger
   enabled="y"
   match="^(Bob|Mark) (Good|Fair|Awful)$"
   regexp="y"
   send_to="12"
   sequence="100"
  >
  <send>
statuses = statuses or {} -- ensure table exists

statuses ["%1"] = "%2"  -- store his status
</send>
  </trigger>
</triggers>


The above example saves the status of Bob or Mark in the statuses table.

Then when you know you have reached the end of the list of statuses, you could examine the table, first seeing if anyone is "awful" and second seeing if that was the tank.

A simple example would be:


for name, status in pairs (statuses) do
  if status == "Awful" and name == "Bob" then
    Send ("c 'heal' " .. name)
  end -- if needs curing
end -- for loop


However this only scratches the surface of what you really need. You need to be able to express what you want in plain English (or pseudo code) and then turn it into a script. For example, do you heal Bob twice in a row?


- Nick Gammon

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

Posted by Mstevem   (3 posts)  Bio
Date Reply #6 on Sat 17 Jan 2009 05:41 PM (UTC)
Message
Thanks, that is helpful. I've gotten tables to work pretty consistently after spending time on them yesterday. In your example below,

for name, status in pairs (statuses) do
if status == "Awful" and name == "Bob" then
Send ("c 'heal' " .. name)
end -- if needs curing
end -- for loop


suppose we also want to heal mark and jim but bob has priority to be healed first. we want to heal if the status is either awful or injured. would we then simply add another status examination and trigger? like:

statuses = {"Awful","Injured"}
for name, status in pairs (statuses) do
if status == "(Awful|Injured)" and name == "(Bob)" then
Send ("c 'heal' " .. name)
end
end

for name, status in pairs (statuses) do
if status == "(Awful|Injured)" and name == "(Bob|Mark|Jim)" then
Send ("c 'heal' " .. name)
end
end

So the script would match bob's status with the table first and cure him if needed, then do a match for bob, mark, and jim. The bob/mark/jim match would have equal priority, and be cured in the order of input on the mud screen..am I correct here, or does it not read that way?





Top

Posted by Nick Gammon   Australia  (23,158 posts)  Bio   Forum Administrator
Date Reply #7 on Sat 17 Jan 2009 08:23 PM (UTC)
Message
Well not exactly. I would have an inner and outer loop, like this:



-- some test data

statuses = {
  Bob = "Awful",
  Jim = "Injured",
  Mark = "Good",
 }

priorities = { "Awful",   -- do this first
               "Injured", -- then this
            }

for sequence, priority in ipairs (priorities) do

  for name, status in pairs (statuses) do
    if status == priority then
      Send ("c 'heal' " .. name)
    end  -- if bad
  end   -- for each player

end -- each priority


The outer loop is priorities (I use ipairs here, because that does them in sequence). So it heals everyone who is Awful first, then those that are Injured, and does nothing to the others.

For each priority, it checks if each player is that priority, and then heals them.

Using the test data (normally a trigger would fill up the table), I saw this:


c 'heal' Bob
c 'heal' Jim


This doesn't address the issue of healing the tank first. You might make another loop again (tanks / not tanks) and now have three levels of looping. First level - do the tanks first. Second level - do the Awful ones first. Third level - do each player.

You still have other issues: can you cast two heals in a row, or do you need to wait a second? Also, it doesn't check of you are out of mana.

- Nick Gammon

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

Posted by Mstevem   (3 posts)  Bio
Date Reply #8 on Sun 18 Jan 2009 09:33 PM (UTC)

Amended on Mon 19 Jan 2009 04:33 PM (UTC) by Mstevem

Message
Is it possible to have a simple if, and, then statement to prioritize the tank? For example, I've been working on this script with limited success. The problem is that it only works for the tank and will not do a second status scan for the entire group as a whole after checking the tank's status. What I'm trying to do is make it check Jim's status, and if Jim doesn't get healed (because his status is healthy enough), then the script should check the group's status.

I'm not sure why this isn't working. Is else simply the wrong command to use?


statuses = {%1 = "%2",}

for name, status in pairs (statuses) do
if name == "Jim" and status == "%2" then
Send ("c 'heal' Jim")

else

for name, status in pairs (statuses) do
if status == "%2" and name == "%1" then
Send ("c 'heal' " .. name)
end
end
end
end


_______________________________________

I removed this bottom part because I figured it out. I can get the script working fine in immediate now. Your suggestions helped a lot Nick. Thank you.

I still don't understand why the above part won't work.
Top

Posted by TruckDriver22   Denmark  (22 posts)  Bio
Date Reply #9 on Wed 21 Jan 2009 05:12 AM (UTC)
Message
Nick you said... You still have other issues: can you cast two heals in a row, or do you need to wait a second? Also, it doesn't check of you are out of mana.

Yea i got the heal trigger to work good.. and now i did notice that casting 2 heals in a row like that can cause some serious issue with lag.

pkbashing = {"Nick","Bob","Steve"}
targetlist = {"Bob","Steve",}
for sequence, priority in ipairs (targetlist) do
for i, v in pairs (pkbashing) do
if v == priority then
(send only one please insert code here)
Send ("bash " .. v)
end
end
end
pkbashing = {}

give me this
bash Bob
bash Steve

But i dont wanna bash steve untill Bob is done being bashed?
how do i tell it to stop

i wanna type in only send once 1 or something


I am going to get one of them dummies books on how to script in lua to play texted based rpgs.. haha

Click bang... GAME OVER!
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.


23,484 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.