Mushclient Questions

by Esano

Back to Mechanic's Corner.

Unknown2009-03-03 18:50:39
Download. Extract. Open world. Install. Done.
Kio2009-03-06 17:28:17
QUOTE (Zarquan @ Feb 16 2009, 07:29 PM) <{POST_SNAPBACK}>
1. Make a trigger to capture your prompt.
2. Omit from output, of course.
3. Set that trigger up with the name of a function in the Script box (not the big Value box).
4. That function receives a list of all the styles, so you can manipulate them or re-echo them.
5. Make a script function that looks kinda like this and add your own bits:
CODE
function decorate_prompt(name, line, wildcards, styles)
  for _, v in ipairs(styles) do
    ColourTell(RGBColourToName(v.textcolour), RGBColourToName (v.backcolour), v.text)
  end

  Note("")
end


Alright, so I want my prompt to look exactly like it normally does. HOWEVER, I want to add alerts in the front when I'm being targetted by an instakill, and also add things to the end of it (timestamp, target prone status, my prone status, etc.). I'm pretty sure I can figure that stuff out. My problem is I have about no clue as to what you said here, heh. Any way to clarify for someone who's just starting? Also, I use VBscript (it's a little easier for me to understand), not Lua. I know that changes syntax, but I know/can find the syntax differences. Regardless, will that affect anything?

Thanks!
Isuka2009-03-06 17:56:57
QUOTE (Kio @ Mar 6 2009, 09:28 AM) <{POST_SNAPBACK}>
Alright, so I want my prompt to look exactly like it normally does. HOWEVER, I want to add alerts in the front when I'm being targetted by an instakill, and also add things to the end of it (timestamp, target prone status, my prone status, etc.). I'm pretty sure I can figure that stuff out. My problem is I have about no clue as to what you said here, heh. Any way to clarify for someone who's just starting? Also, I use VBscript (it's a little easier for me to understand), not Lua. I know that changes syntax, but I know/can find the syntax differences. Regardless, will that affect anything?

Thanks!

Lua is really worth taking the time to learn. If you're already familiar with other scripting languages, Lua has a light learning curve and is quite powerful. Plus, you get the advantage of working with the language that MUSHclient's creator seems to favor.
Kio2009-03-06 20:19:18
Taking your advice and tinking out everything I have in Lua. I'm annoyed, tired, and mildly distracted.

if("%1"="right") AND ("%2"="arm")Then

...how do I do this in Lua?

*emocry*
Isuka2009-03-06 20:27:29
QUOTE (Kio @ Mar 6 2009, 12:19 PM) <{POST_SNAPBACK}>
Taking your advice and tinking out everything I have in Lua. I'm annoyed, tired, and mildly distracted.

if("%1"="right") AND ("%2"="arm")Then

...how do I do this in Lua?

*emocry*


if "%1" == "right" and "%2" == "arm" then << do something >> end

Kio2009-03-07 01:51:35
Superthanks!

ETA: New question!

I'm running my sipping off my prompt.

^(\\d+)h\\, (\\d+)m\\, (\\d+)e\\, (\\d+)p.*? (.*?)\\-

send:

if "CInt(%1)" < "CInt(@siphealth)" and "@sipbalance" == "1" then
Execute ("siph")
end

This works... ish. It doesn't fire when the prompt comes up. Instead it fires when the prompt scrolls by.

Example:

1552h, 1650m, 975e, 10p, 6900en, 6900w ex-
With a sudden leap and a mechanical click, a clockwork serpent clamps his wickedly sharp teeth down on your leg, emitting a mechanical growl.
1398h, 1650m, 975e, 10p, 6900en, 6900w ex-sip health
Without warning, a gear suddenly detaches itself from its current position, flies over your head and inserts itself in position at the opposite end of the structure.
1398h, 1650m, 975e, 10p, 6900en, 6900w ex-
You bleed 9 health.
1389h, 1650m, 975e, 10p, 6900en, 6900w ex-You take a drink from a sapphire vial.
The potion heals and soothes you.

It didn't fire until the bolded came up.

How can I fix this?
Unknown2009-03-07 06:51:36
if "psy_vamp" == false then SetVariable("psy_vamp", true) end

What's wrong with this? Something with the if statement I'm sure. This won't set psy_vamp to true for some reason.
Isuka2009-03-07 06:54:26
QUOTE (Vecanamu @ Mar 6 2009, 10:51 PM) <{POST_SNAPBACK}>
if "psy_vamp" == false then SetVariable("psy_vamp", true) end

What's wrong with this? Something with the if statement I'm sure. This won't set psy_vamp to true for some reason.


"psy_vamp" can't be false, because it's a string (rather than a reference to a variable). You probably want:

CODE
if not GetVariable("psy_vamp") then SetVariable("psy_vamp",true) end
Isuka2009-03-07 06:58:23
QUOTE (Kio @ Mar 6 2009, 05:51 PM) <{POST_SNAPBACK}>
Superthanks!

ETA: New question!

I'm running my sipping off my prompt.

^(\\d+)h\\, (\\d+)m\\, (\\d+)e\\, (\\d+)p.*? (.*?)\\-

send:

if "CInt(%1)" < "CInt(@siphealth)" and "@sipbalance" == "1" then
Execute ("siph")
end

This works... ish. It doesn't fire when the prompt comes up. Instead it fires when the prompt scrolls by.

Example:

1552h, 1650m, 975e, 10p, 6900en, 6900w ex-
With a sudden leap and a mechanical click, a clockwork serpent clamps his wickedly sharp teeth down on your leg, emitting a mechanical growl.
1398h, 1650m, 975e, 10p, 6900en, 6900w ex-sip health
Without warning, a gear suddenly detaches itself from its current position, flies over your head and inserts itself in position at the opposite end of the structure.
1398h, 1650m, 975e, 10p, 6900en, 6900w ex-
You bleed 9 health.
1389h, 1650m, 975e, 10p, 6900en, 6900w ex-You take a drink from a sapphire vial.
The potion heals and soothes you.

It didn't fire until the bolded came up.

How can I fix this?


I had this same problem when I switched to MUSHclient. MUSH doesn't have an option to trigger on prompt, it requires a newline. You can emulate a newline by setting "Convert IAC EOR/GA to new line" option in CTRL+G>Output or by configuring lusternia to add a newline to the prompt with CONFIG PROMPT ADD LINEBREAK (which is what I do).

EDIT:
Looking at this:
QUOTE
if "CInt(%1)" < "CInt(@siphealth)" and "@sipbalance" == "1" then

I see a problem. You're comparing strings, not functions. Anything inside the quotation marks is considered a literal string.
I have to wonder if this is firing when you really want it to.
Also, that syntax for casting to an interger doesn't work with Lua. Lua handles variable types very casually in general.
What I imagine you want is...
CODE
local siphealth = <>
local sipbalance = <>
if tonumber("%1") < tonumber(siphealth) and sipbalance == 1 then << do code >> end

Unknown2009-03-07 07:03:20
That still didn't work...

Isuka2009-03-07 07:13:10
QUOTE (Vecanamu @ Mar 6 2009, 11:03 PM) <{POST_SNAPBACK}>
That still didn't work...

I need to see the entire contents to pick out where it went wrong. Also, are you calling this from a script file, or within the trigger itself?
Unknown2009-03-07 07:18:45
I have an alias that has the code I posted(now your code) and I made a variable called 'psy_vamp' and set it to false to test it.

I'm not exactly sure what you're asking because I'm not very familiar with MUSHclient, but I sent the alias to script.
Esano2009-03-07 07:23:49
Chances are it's not looking for boolean, but rather for string. Try ...

if GetVariable("psy_vamp") == "false" then SetVariable("psy_vamp","true") end
Unknown2009-03-07 07:28:08
That works.

I wasn't getting the GetVariable() part put I understand now.

Thank you
Unknown2009-03-07 12:24:13
Yes, it's important to note that GetVariable always, always, always returns a string, no matter what you stored in the variable.
Unknown2009-03-07 23:01:37
Old post gone.

Okay, solved the problem with the regex not capturing, now MUSH is giving me a hard time.

My trigger is matching on:

CODE
^\\| Health \\: (\\d+)\\/(\\d+)     Endurance \\: (\\d+)\\/(\\d+)       Power    \\: (\\d+)p       \\|(\\n)\\| Mana   \\: (\\d+)\\/(\\d+)       Willpower \\: (\\d+)\\/(\\d+)       Reserves \\: (\\d+)\\%       \\|(\\n)\\| Ego    \\: (\\d+)\\/(\\d+)     Mindset   \\: (\\w+)      Esteem   \\: (\\d+)\\%        \\|$


And sending:

CODE
SetVariable("health", "%1")
SetVariable("maxhealth", "%2")
SetVariable("endurance","%3")
SetVariable("maxendurance", "%4")
SetVariable("power",  "%5")
SetVariable("mana", "%6")
SetVariable("maxmana", "%7")
SetVariable("willpower", "%8")
SetVariable("maxwillpower", "%9")
SetVariable("reserves", "%10")
SetVariable("ego", "%11")
SetVariable("maxego", "%12")
SetVariable("mindset", "%13")
SetVariable("esteem", "%14")


to the script. All above variables are set to nil.

Ideas?
Unknown2009-03-08 03:07:28
Two things I can think of right away:
1. You should match on a variable number of spaces in many places, using \\s+, because the number of digits or characters will shift things around a little and cause the trigger to not match at all.
2. When you use %n above 9, you need angle brackets, so they'll look like %<10> and so on.
Kio2009-03-08 05:47:50
Another If problem:

Alias: ^j (.*?) (.*?)$

Send (to script):

if "%1 == u" then
Execute ("kata perform @target 1jak%2 2jak%2 2jakraze%2 3jak%2 4jak%2 4jak%2 4jak%2")
elseif "%1 == i" then
Execute ("kata perform @target 2jakraze%2 3jak%2 4jak%2 4jak%2 4jak%2 4jak%2 4jak%2")
elseif "%1 == o" then
Execute ("kata perform @target 3jak%2 4jak%2 4jak%2 4jak%2 4jak%2 4jak%2 4jak%2")
end


Works when I do, for example, "j u head." However, when I do "j i head," it acts as if I did "j i head."
Any hints?

p.s. MUSH makes me feel stoopad. =
Unknown2009-03-08 06:21:41
Try changing the send to:

CODE
if %1 == "u" then
Execute ("kata perform @target 1jak%2 2jak%2 2jakraze%2 3jak%2 4jak%2 4jak%2 4jak%2")
elseif %1 == "i" then
Execute ("kata perform @target 2jakraze%2 3jak%2 4jak%2 4jak%2 4jak%2 4jak%2 4jak%2")
elseif %1 == "o" then
Execute ("kata perform @target 3jak%2 4jak%2 4jak%2 4jak%2 4jak%2 4jak%2 4jak%2")
end
Isuka2009-03-08 06:22:02
QUOTE (Kio @ Mar 7 2009, 09:47 PM) <{POST_SNAPBACK}>
Another If problem:

Alias: ^j (.*?) (.*?)$

Send (to script):

if "%1 == u" then
Execute ("kata perform @target 1jak%2 2jak%2 2jakraze%2 3jak%2 4jak%2 4jak%2 4jak%2")
elseif "%1 == i" then
Execute ("kata perform @target 2jakraze%2 3jak%2 4jak%2 4jak%2 4jak%2 4jak%2 4jak%2")
elseif "%1 == o" then
Execute ("kata perform @target 3jak%2 4jak%2 4jak%2 4jak%2 4jak%2 4jak%2 4jak%2")
end


Works when I do, for example, "j u head." However, when I do "j i head," it acts as if I did "j i head."
Any hints?

p.s. MUSH makes me feel stoopad. =