Command Prompt with no Return

Posted by Nemix on Mon 16 Apr 2007 03:09 PM — 10 posts, 41,730 views.

#0
Ok I'm trying to grab hp, sp, st changes and put them on the output, easier to show an example:

This is what normal looks like:

<1617hp 1727sp 2217st>

What I want to do..

<1717hp 1727sp 2117st> +100, 0, -100

Problem I'm having is that its not triggering off of the latest line and it doesn't show the +/-'s on the same line.
I recently made a damage script to show how hurt whatever I was fighting is and I had to omit from output and add in 0% for the whole line. Though even if I do that I still need help, since it won't replace it until the next line is recieved.

trigger on "^<(\d+)hp (\d+)sp (\d+)st>(.*?)$"

hpchange = (%1 - hpchange)
spchange = (%2 - spchange)
stchange = (%3 - stchange)
world.note hpchange & " " & spchange & " " & stchange & vbcrlf
hpchange = %1
spchange = %2
stchange = %3



Example of what happens:
<1717hp 1727sp 2117st>
+100, 0, -100

<1717hp 1727sp 2217st>

I believe it won't trigger off the latest line because there is nothing to indicate a new line yet, any idea how to trigger from it or fix this?
Netherlands #1
Try using the IAC EOR/GA option in Configuration>Display. In most cases, that will terminate your prompt with a new line, in turn giving you the possibility to trigger on it. In the trigger of your prompt, you should omit the trigger from output and instead output it yourself. That way, it will be possible to output your entirely customized prompt.
#2
Still no go, anything else to try?
USA #3
Some muds allow you to put a carriage return in your prompt. On the mud I play on, I have a "%c" at the end of my prompt to force a new line in order to make sure my prompt catcher works.
#4
You'll have to set the trigger as "omit from output" = true. This is in your trigger properties window.

Otherwise you are already calculating the differences based on inputs you want to display. You merely need to keep the originals and re-display the originals beforehand.

Your output:
world.note hpchange & " " & spchange & " " & stchange & vbcrlf

should be:
(omit from output)
world.note "<" %1 & "hp " & %2 & "sp " & %3 & "st> " & hpchange & " " & spchange & " " & stchange & vbcrlf

This would give you the desired output you want without having to worry about changing other settings outside of the trigger.
#5
That wasn't exactly my problem, I could do that easy enough but it doesn't show up until the next line is sent.

I tried the plugin's on this page here:
http://mushclient.com/forum/?id=7430

But for some reason all this did was hide the prompt until the next line was recieved.
Australia Forum Administrator #6
The regexp in the plugin needs to match what you are getting as your prompt. You have shown what your prompt looks like, so can you post the regexp line from the plugin?

The original one read:


<!ENTITY prompt_regexp "^Alisha \- \((.*?)\/(.*?) (.*?)\/(.*?) (.*?)\/(.*?) (.*?) (.*?)\/(.*?)\) (.*?)$" >
]>


But that definitely won't work with your prompt, because it is different.
#7
I think I tried a couple different phrases to match but this is what it is currently:

<!ENTITY prompt_regexp "^\\<(.*?)hp (.*?)sp (.*?)st\\>$" >

It seems to find the prompt but then it doesn't send the prompt until the next line & hides the newest one again.
Australia Forum Administrator #8
Try this:


<!ENTITY prompt_regexp "^\<(\d+)hp (\d+)sp (\d+)st\>" >
#9
I'm playing a mud called Materia Magica, once known as Moongate, www.materiamagica.com:4000.

Ok, I think its finding it, just not returning anything. Here's an example of while its on vs while the plugin is off,

On:
"

c 'cure light'
<2658hp 2680sp 2635st> You begin to speak the words of the spell...

<2658hp 2680sp 2635st>
You have completed your casting.
A warm, blue aura surrounds you for a moment, then softly fades.
You feel better!

"

It seems to be missing some prompts and stopping a newline from some of them.

Off:
"
<2658hp 2707sp 2636st>
c 'cure light'
You begin to speak the words of the spell...

<2658hp 2707sp 2636st>
You have completed your casting.
A warm, blue aura surrounds you for a moment, then softly fades.
You feel better!

<2658hp 2673sp 2636st>
"


Here's the whole plugin I got from the other post:

<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE muclient[
<!ENTITY prompt_regexp "^\<(\d+)hp (\d+)sp (\d+)st\>" >
]>
<!-- MuClient version 3.59 -->

<!-- Plugin "Add_Newline_To_Prompt" generated by Plugin Wizard -->

<muclient>
<plugin
name="Add_Newline_To_Prompt"
author="Nick Gammon"
id="8316c19c35a9ebdb46055874"
language="Lua"
purpose="Adds a newline to prompt lines"
date_written="2004-12-13 12:08:00"
requires="3.59"
version="1.0"
>
<description trim="y">
Detects prompt lines without a newline, and if found, adds one.

Change ENTITY line on 3rd line of plugin to be a regular expression
that matches your prompt.

</description>

</plugin>

<!-- Script -->

<script>

re = rex.new ("&prompt_regexp;")

<![CDATA[

partial = "" -- partial line from last time through

function OnPluginPacketReceived (s)

-- add packet to what we already have (excluding carriage-returns)

partial = partial .. string.gsub (s, "\r", "")

t = {} -- table of lines to be returned

-- iterate over each line

partial = string.gsub (partial, "(.-)\n",
function (line)
table.insert (t, line)
return ""
end)


-- look for prompt

if (re:match (partial)) then
table.insert (t, partial)
partial = ""
end -- if found prompt

if table.getn (t) > 0 then
table.insert (t, "") -- to get final linefeed
end -- if

-- return table of lines, concatenated with newlines between each one
return table.concat (t, "\n")

end -- function OnPluginPacketReceived
]]>
</script>

</muclient>