PDA

View Full Version : DownstreamHook "Song Status"



Drunken Durfin
12-15-2016, 11:30 AM
I'm trying to capture a couple of things out of the return for the bard command "song status"


You are currently singing: Fortitude Song
Song of Luck
Song of Valor
Song of Mirrors
Song of Sonic Disruption

The effects of your magical medley have faintly begun to wane. It will be a couple of minutes before your medley renews. Your current renewal cost is 51 mana.

I'd like to be able to capture "Song of Sonic Disruption" and the value for whatever the renewal cost is at the end. I've tried several variations, but all I can ever seem to get it to hit on is the first line "You are currently...", nothing else.

I gave up on that route and went to the Stop List return to try and grab it there, but met with the same result. Using this code:


if server_string =~ /STOP SINGING 1030 - Song of Sonic Disruption/
echo "SD Hit fired: #{server_string}"
canRenew = true
nil
elsif server_string =~ /You can currently stop doing the following|STOP/
echo "You Can and/or STOP fired: #{server_string}"
DownstreamHook.remove('check_SonicDisruptionActive ')
nil
else
echo "Else fired: #{server_string}"
server_string
end

Still, the only thing I can get it to hit on is the first line, "You can currently stop...":


You can currently stop doing the following:

STOP SINGING ALL SPELLSONGS
STOP SINGING 1003 - Fortitude Song
STOP SINGING 1006 - Song of Luck
STOP SINGING 1010 - Song of Valor
STOP SINGING 1019 - Song of Mirrors
STOP SINGING 1030 - Song of Sonic Disruption
STOP 401 - Elemental Defense I
STOP 406 - Elemental Defense II
STOP 414 - Elemental Defense III
STOP 425 - Elemental Targeting
STOP 430 - Elemental Barrier
STOP {Target}
So, I'm guessing these things are related.

Thanks.

Drunken Durfin
12-15-2016, 02:05 PM
Output with tags echo'ing


>Song status

You are currently singing: Fortitude Song
Song of Luck
Song of Valor
Song of Mirrors
Song of Sonic Disruption

Your song magic remains strong. It will be several minutes before your medley renews. Your current renewal cost is 51 mana.
>
[exec1: <output class="mono"/>]
[exec1: You are currently singing: Fortitude Song]
[exec1: Song of Luck]
[exec1: Song of Valor]
[exec1: Song of Mirrors]
[exec1: Song of Sonic Disruption]
[exec1: <output class=""/>]
[exec1: ]
[exec1: Your song magic remains strong. It will be several minutes before your medley renews. Your current renewal cost is 51 mana.]
[exec1: <prompt time="1481824983">&gt;</prompt>]

>Stop list

You can currently stop doing the following:

STOP SINGING ALL SPELLSONGS
STOP SINGING 1003 - Fortitude Song
STOP SINGING 1006 - Song of Luck
STOP SINGING 1010 - Song of Valor
STOP SINGING 1019 - Song of Mirrors
STOP SINGING 1030 - Song of Sonic Disruption
STOP {Target}
[exec1: You can currently stop doing the following:]
[exec1: ]
>
[exec1: <output class="mono"/>]
[exec1: <a exist="-10987075" coord="2524,1746" noun="singing">STOP SINGING ALL SPELLSONGS</a>]
[exec1: <a exist="-10987075" coord="2524,1746" noun="singing 1003">STOP SINGING 1003 - Fortitude Song</a>]
[exec1: <a exist="-10987075" coord="2524,1746" noun="singing 1006">STOP SINGING 1006 - Song of Luck</a>]
[exec1: <a exist="-10987075" coord="2524,1746" noun="singing 1010">STOP SINGING 1010 - Song of Valor</a>]
[exec1: <a exist="-10987075" coord="2524,1746" noun="singing 1019">STOP SINGING 1019 - Song of Mirrors</a>]
[exec1: <a exist="-10987075" coord="2524,1746" noun="singing 1030">STOP SINGING 1030 - Song of Sonic Disruption</a>]
[exec1: <a exist="-10987075" coord="2524,1746" noun="Ifor">STOP {Target}</a>]
[exec1: <output class=""/>]
[exec1: <prompt time="1481825076">&gt;</prompt>]

Tillmen
12-15-2016, 02:20 PM
def check_disruption
squelching = false
hook_name = 'squelch-song-status'
hook_proc = proc { |s|
if squelching
if s =~ /<output/
s
elsif s =~ /<prompt/
DownstreamHook.remove(hook_name)
s
else
nil
end
elsif s =~ /^You are currently singing/
squelching = true
nil
else
s
end
}
DownstreamHook.add(hook_name, hook_proc)
status_tags
clear
silence_me unless undo_silence = silence_me
put 'song status'
silence_me if undo_silence

active = false
cost = nil
while line = get
if line =~ /You are currently singing/
if line =~ /Song of Sonic Disruption/
active = true
end
while line = get
if line =~ /<prompt/
break
elsif line =~ /Song of Sonic Disruption/
active = true
elsif line =~ /current renewal cost is (\d+) mana/
cost = $1.to_i
end
end
break
end
end
return h = { :active => active, :cost => cost }
end

foo = check_disruption
if foo[:active]
# something
end
if foo[:cost] > 9000
# something else
end

Drunken Durfin
12-15-2016, 04:08 PM
Works like a champ. Thank you very much for your assistance.

Durgrimst
12-16-2016, 01:27 PM
You are playing again???

Donquix
12-16-2016, 02:00 PM
In shattered. He's not a real boy.

Drunken Durfin
12-16-2016, 03:10 PM
You are playing again???

I blame Casis. It is all his fault.

It is less "playing" and more "I wonder if I can code a script that will do X?" kind of an exercise. The new will wear off, or I will get overly frustrated, and that will be the end of it again. I was mostly lured by the 2 free months of Prime, which made this a $5/month investment when you tack on the Shattered sub. If they would make Shattered a stand-alone $5 subscription I would most likely stay, but I'm not holding my breath.

Drunken Durfin
12-20-2016, 10:27 AM
Before I carry over this code to other things, and inadvertently screw something up, what is the purpose of "status_tags" and "clear" the the section below?


DownstreamHook.add(hook_name, hook_proc)
status_tags
clear

Luxelle
12-20-2016, 03:38 PM
Nicely done!

Donquix
12-20-2016, 04:08 PM
Before I carry over this code to other things, and inadvertently screw something up, what is the purpose of "status_tags" and "clear" the the section below?


DownstreamHook.add(hook_name, hook_proc)
status_tags
clear

https://gswiki.play.net/Lich_scripting_reference#status_tags

https://gswiki.play.net/Lich_scripting_reference#clear