PDA

View Full Version : LICH: thoughtget?



Renian
05-29-2008, 03:25 PM
Is there a command like "get" that will get a line from the thought window instead of the game window?

Renian
06-01-2008, 03:46 PM
No one knows?

i r sad. :(

Peanut Butter Jelly Time
06-01-2008, 03:50 PM
Not using lich = makes 40 things much less complicated.


























...and sure, it also makes about 400 things much more complicated, but shush.

Shaelun
06-04-2008, 09:30 PM
Not using lich = makes 40 things much less complicated.

...and sure, it also makes about 400 things much more complicated, but shush.

Hahah... true. I guess a 10:1 ratio in its favor isn't so bad, though, eh :)


Renian: no, there isn't, but there should be.



# Provides a "thought_get" method for StormFront.


# Setup. $thought_array doesn't have to be global for this to work, but it opens the possibility of other scripts tinkering with it if they have a reason to
toggle_status
$thought_array = []

# Define the ``thought_get'' method for other scripts to use
def thought_get

fail "Doesn't work without SF..." if not $stormfront
wait_while { $thought_array.empty? }

return $thought_array.shift

end

# Now sit around and watch for thoughts
loop {
line = get
if regexp = line.match(/<pushStream id=['"]thoughts['"][^>]+>/i)

msg = regexp.post_match.gsub(/<[^>]+>/, '')
$thought_array.push(msg)

until (line = get) =~ /<popStream(?: id=['"]thoughts['"])?\/>/i
$thought_array.push( line.gsub(/<[^>]+>/, '') )
end

end
}

That should do it... just stick it in a script, run the script, and hopefully it'll work.

Renian
06-05-2008, 12:36 AM
Problem: I use Wizard now, lol.

Lich was causing SF to A-SPLODE.

Shaelun
06-07-2008, 12:32 AM
Problem: I use Wizard now, lol.


Oh. Well in that case... it's a whole lot easier. Even if you have Wizard's "compress incoming thoughts," option enabled so that messages are only one line, the server still sends them in two lines. I can't find a log, so take this with a grain of salt (you can always use Lich's echo.lic script to check what a script actually ends up seeing), but it's basically always:


You hear the faint thoughts of Shaelun echo in your mind:
"Insert pithy quote here."

So, since I feel like it, here... modified to work with SF & Wizard both:


# Provides a "thought_get" method.


# Setup. $thought_array doesn't have to be global for this to work, but it opens the possibility of other scripts tinkering with it if they have a reason to
toggle_status if $stormfront
$thought_array = []

# Define the ``thought_get'' method for other scripts to use
def thought_get

wait_while { $thought_array.empty? }
$thought_array.shift

end

monitor_proc = if $stormfront
# What to do if we're running with SF...
proc {
line = get
if regexp = line.match(/<pushStream id=['"]thoughts['"][^>]+>/i)

msg = regexp.post_match.gsub(/<[^>]+>/, '')
$thought_array.push(msg)

until (line = get) =~ /<popStream(?: id=['"]thoughts['"])?\/>/i
$thought_array.push( line.gsub(/<[^>]+>/, '') )
end

end
}
else
# What to do if we're running with Wizard...
proc {
matchobj = waitforre(/You hear the faint thoughts of ([^\s]+) echo in your mind/i)

line = sprintf("%s: %s", matchobj.captures.first, get)
$thought_array.push(line)
}
end

# Now sit around and watch for thoughts
loop(&monitor_proc)

Usually I value an easy-to-understand script over a short one, but oh well.