Priorities

Posted by TruckDriver22 on Wed 14 Jan 2009 03:31 AM — 10 posts, 31,022 views.

Denmark #0
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.!!!

Denmark #1
--------------------------------------------------------
Bob awful
Mark awful
c 'heal' mark

thats what i want to happon
Australia Forum Administrator #2
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.
Denmark #3
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.
Amended on Thu 15 Jan 2009 02:41 AM by TruckDriver22
#4
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?
Australia Forum Administrator #5
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?

Amended on Fri 16 Jan 2009 04:34 AM by Nick Gammon
#6
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?





Australia Forum Administrator #7
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.
#8
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.
Amended on Mon 19 Jan 2009 04:33 PM by Mstevem
Denmark #9
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