Imperian Blesser

Post Reply
Magnix
Posts: 5
Joined: Mon Dec 31, 2012 7:54 pm

Imperian Blesser

Post by Magnix »

I've been trying for a while to get a queueable "Blesser" script running for Imperian. I've scrapped it a few times, and I'm hoping someone can help out. Basically, what I'd like it to do is:

Alias: ^bless (\w+)$
This alias will add PLAYER to a table. If it's not currently blessing someone else already, begin blessing that person.

The blessings are:
bless X frostshield
bless X willpower
bless X endurance
bless X thermalshield
bless X earthshield

If in the middle of the first players blessings, I want to add a 2nd person, I want to do "bless PLAYER" and have it add the 5 blessings to the queue to be done to that person.

if I get attacked, I'd like to:
Alias: ^pause bless$
Alias: ^clear ?bless$
or
Alias: ^show ?bless$
(to see how much longer I have till it ends)

If paused, I want to:
Alias: ^resume bless$

Trigger lines may be:
^You call upon your faith and bestow the (\w+) blessing upon .+\.$
Wildcard = Earthshield | Frostshield | Thermalshield | Willpower | Endurance

Each blessing takes 3.8 seconds of Equilibrium.

EDIT: Error handling triggers include:
^You have already been blessed with that blessing.$
^(\w+) has already been blessed with that blessing.$

The system would need to know what blessing it attempted last, remove it from the table (or +1) and do next. There is no EQ lost on attempted blessings that were already there.


Any thoughts on how to construct this? I'm a beginner in LUA (also known as terrible)

Lezard
Posts: 36
Joined: Wed Aug 29, 2012 6:47 pm

Re: Imperian Blesser

Post by Lezard »

This was typed up in notepad with no testing, so it may not be 100% accurate. But you get the picture.
Code: [show] | [select all] lua
blessTime = 3.8
function loadBlessings()
  blessings = {"frostshield", "willpower", "endurance", "thermalshield", "earthshield"}
  blessingTarget = ""
end
function startBlessing(targ) -- Alias: ^bless (\w+)$
  loadBlessings()
  blessing = true
  blessingTarget = targ
  send("bless "..blessingTarget.." "..blessings[1])
  table.remove(blessings, 1)
  tempTimer(blessTime, [[checkBlessing()]])
end
function checkBlessing()
  if blessing and equilibrium then
	if blessings[1] then
	  send("bless "..blessingTarget.." "..blessings[1])
	  table.remove(blessings, 1)
	  tempTimer(blessTime, [[checkBlessing()]])
	end
  end
end
function pauseBlessing() -- Alias: ^toggle ?bless$
  blessing = not blessing
  if blessing then
    echo("\nBlessing Unpaused")
    checkBlessing()
  else
    echo("\nBlessing Paused")
  end
end
function clearBlessing() -- Alias: ^clear ?bless$
  blessings = {}
  echo("\nBlessings Cleared")
end
function showBlessingTime() -- Alias: ^show ?bless$
  local curTime
  for _, v in pairs(blessings) do
    curTime = curTime + blessTime
  end
  echo("\nThe blessings will finish in approximately "..curTime.." seconds!")
end
Any comments, concerns, questions?

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

Re: Imperian Blesser

Post by Delrayne »

Nicely done I'd say. Left out the queue for people though. But still beggars can't be choosers right?

Magnix
Posts: 5
Joined: Mon Dec 31, 2012 7:54 pm

Re: Imperian Blesser

Post by Magnix »

Hey guys,

Thanks a lot for the assistance. With a few tweaks, I got the system working just fine for what I need it to do. I spent some time trying to make it do some other things, and couldn't, but regardless, thank you for the starting point!

I'll post what I have so far, which has been tested to work. Here are some points I was curious about:
1. When does blesser ever = false (outside of toggle bless)?
2. How can I add "You have already been blessed with that blessing." to cecho: "cecho("\n<red>[<white>Blesser<red>]: <white>User already has "..blessings[1]) ? because doing that, simply, doesn't work.
3. I added cecho("\n<red>[<white>Blesser<red>]: <white>Blessing Finished!") to checkBlessing and it only fired when I already had all 5x blessings already. It wouldn't fire on the following EQ gained after blessing with the last bless, most likely because I could not figure out where to put it so that while blessing = true but blessings = nil, then blessings = false and then cecho the finished text.

SCRIPT:
Code: [show] | [select all] lua
blessing = false
blessTime = 4.0
function loadBlessings()
  blessings = {"frostshield", "willpower", "endurance", "thermalshield", "earthshield"}
  blessingTarget = ""
end
function startBlessing(targ) -- Alias: ^bless (\w+)$
  loadBlessings()
  blessing = true
  blessingTarget = targ
  send("bless "..blessingTarget.." "..blessings[1])
  table.remove(blessings, 1)
end

function checkBlessing()
			if blessing then
        if blessings[1] then
          send("bless "..blessingTarget.." "..blessings[1])
          table.remove(blessings, 1)
		end
	end
end

function pauseBlessing() -- Alias: ^toggle ?bless$
  blessing = not blessing
  if blessing then
    cecho("\n<red>[<white>Blesser<red>]: <white>Blessing Unpaused")
    checkBlessing()
  else
    cecho("\n<red>[<white>Blesser<red>]: <white>Blessing Paused")
  end
end

function clearBlessing() -- Alias: ^clear ?bless$
  blessings = {}
	blessing = false
  echo("\nBlessings Cleared")
end

function showBlessingTime() -- Alias: ^show ?bless$
  local curTime = 0.0
  for _, v in pairs(blessings) do
    curTime = curTime + blessTime
  end
  cecho("\n<red>[<white>Blesser<red>]: <white>The blessings will finish in approximately "..curTime.." seconds!")
end
TRIGGERS:
You have regained your mental equilibrium. ---> checkBlessing()
^(\w+) has already been blessed with that blessing.$ ---> checkBlessing()
You have already been blessed with that blessing. --> checkBlessing()

Alias: ^bless (\w+)$
targ = matches[2]
startBlessing(targ)

The rest is all about the same. I removed the tempTimers in favour of an EQ trigger, since blessing time 3.8 varies a lot on whether you have a heavier shield on, without inspiration up, and/or any sort of lag.

local curTime was nil, so I just initialized it as local curTime = 0.0. Just for the sake of "show bless" working. Which isn't necessary, really, if the system doesn't queue. Which is fine.

Magnix
Posts: 5
Joined: Mon Dec 31, 2012 7:54 pm

Re: Imperian Blesser

Post by Magnix »

Oh, in case you just want the whole package, I'll append it here.
Attachments
Blesser.xml
(6.75 KiB) Downloaded 330 times

User avatar
Vadi
Posts: 4844
Joined: Sat Mar 14, 2009 3:13 pm

Re: Imperian Blesser

Post by Vadi »

Put it up in the scripts section, too

Magnix
Posts: 5
Joined: Mon Dec 31, 2012 7:54 pm

Re: Imperian Blesser

Post by Magnix »

Vadi wrote:Put it up in the scripts section, too
Good idea. It's not mine to put up, though. I wanted to see to its tweaks a bit first and then get it posted, possibly.

Post Reply