MUSHClient help.

by Ilyarin

Back to Mechanic's Corner.

Ilyarin2009-04-29 10:14:23
I can't get my alias to compile properly. I'm sure this is relatively simple, but I've not used mushclient/lua for a while.

Below is the trigger pattern, value, and error.

^\\s*(kill|k)\\s*(\\d+)?\\s*$

--

if "%0" == "kill" or "%0" == "k" then
SetVariable("killing_number","1")
SetVariable("killing","1")
elseif %2 == 0 then
SetVariable("killing_number","0")
SetVariable("killing","0")
elseif %2 >= 2 then
SetVariable("killing_number","%2")
SetVariable("killing","1")
end

Execute("killcheck")

--

Compile error
World: Aetolia
Immediate execution
:5: unexpected symbol near '=='

===

It fires correctly when using a syntax such as "kill 5", but falls down when I try to use just "kill" or "k" (in which case it should fire the first if section). I assume it's because there is no %2 value in this circumstance. Anyone know how to adjust it to fit my need?

Thanks.
Unknown2009-04-29 10:54:49
Pattern:
CODE
^\\s*k(?:ill)?(?:\\s+(\\d+))?\\s*$


Script:
CODE
if #"%1" == 0 then
  SetVariable("killing_number","1")
  SetVariable("killing","1")
elseif "%1" == "0" then
  SetVariable("killing_number","0")
  SetVariable("killing","0")
elseif tonumber("%1") >= 2 then
  SetVariable("killing_number","%1")
  SetVariable("killing","1")
end
Execute("killcheck")


(Off the top of my head. Untested.)
Chade2009-04-30 04:15:49
Ok, little help please:

Trying to make a trigger which captures my targets room number from scent. Standard output looks like

You make out the scent of Celina coming from before the Master Ravenwood Tree. (1)
You make out the scent of Dowapaa coming from The Black Feather.
You make out the scent of Astraea coming from putrefied glen. (3,...)
You make out the scent of Kirovera coming from a dimly-lit archives. (3606)
You make out the scent of Amani coming from Arcane Library.
You make out the scent of Runa coming from before the Master Ravenwood Tree. (1)
You make out the scent of Unalescia coming from before the Master Ravenwood Tree. (1)

It's the line with Astraea in that I want help with.

Basic trigger looks like this, but it's not working, I know something is wrong with the bit where I'm supposed to capture (3,...) not figured that one out yet, but even working off the line with Celina in I can't get the following to work:


enabled="y"
expand_variables="y"
group="Chade"
lines_to_match="2"
keep_evaluating="y"
match="^You make out the scent of @target coming from (.+?)\\. \\((\\d+)\\)$"
name="scenttracker_"
regexp="y"
send_to="12"
sequence="100"
>
SetVariable("targetroom_", "%2")




Where am I going wrong?

EDIT: Appears to be a problem with the @target part, dunno why though as my target is definitely set correctly. Also if anyone could tell me how to get \\((\\d+)\\) to match (3,...) I'd be really grateful!

EDIT2: Hmm, something else strange happening, if I substitute @target for (+|.*?@target.*?) and change %2 to %3 it works but instead of giving me the room number I want, it gives me the number of whoever is at the bottom of the list, so if I'd done scent Kirovera on the example above, it would have captured Unalescia's location.
Mariello2009-04-30 05:25:07
In your trigger, I would chance ((\\d+)\\) to ((\\d+)(|\\,\\.\\.\\.)\\)$ This way, you can capture the number whether or not there are non numerical characters following. Additionally, if you are using @target, make sure the "expand variables" flag is checked. However, in the past I find that sometimes using @variables in triggers causes the trigger to not fire stuff in the correct order so that may also be another issue. Anyway, I, personally, would just use (\\w+) instead of @target and do something like this:

if "%1" = world.getvariable("target") then
world.setvariable "targetroom_", "%3"
end if


Don't know Lua so can't give you the exact code but I am sure you can understand what I mean from the Vb example above.
Unknown2009-04-30 11:08:07
A. Mariello is correct that you need to account for the ",..." in the pattern, but I'd use "^You make out the scent of @target coming from .+?\\. \\((\\d+)(?:\\.\\.\\.)?\\)$" to match it most precisely.
B. You might want to use the Ignore Case option, for when your target is set to "astraea" instead of "Astraea," or it won't match.
C. There's no need to match on two lines.
Qival2009-05-01 08:42:57
Ok while I detected the issue using Ethelon's sytem it actually has nothing to do with the system itself but this way you guys know it is VBscript and whats not.

Anyway I was installing his system on my desktop (windows vista ultimate 64 bit) and during installing I got the error that several variable ranges are mismatched (it concerns variables for sipping which have values like ".8"). The client freezes and forcequit is used. I start up the client again, reload all the triggers and script and this time it starts up without a problem, however the sipping variables do not work, all the rest seems to work like a charm. It should probably also be noted the client becomes extremely laggy after this until I reboot the pc.

Now on my laptop (Windows 7 ultimate 64 bit) the system installs perfectly, the sipping works and there is no lag.

Both PCs are using mushclient 4.40 with 'out of the box' settings.

So does anyone have an idea what the problem is with the vista box? Is it using a different version of VBscript (I thought it came with mush)? And does anyone know a fix that does not involve 'install windows 7 or xp' or 'recode in to lua'
Unknown2009-05-01 10:50:02
VBscript comes with Windows, not MUSHclient.

Do you use a non-U.S. locale in Windows, by any chance? Something that maybe uses 0,8 for numbers instead of 0.8?
Aerotan2009-05-03 05:14:46
apparently, in the time since I have last written a program, I have gone retarded. I'm trying to make an alias so that I can send a value to a variable from the command line.

I want to be able to type in something like x krokani and switch my aliases from targeting oozes to targeting krokani. The aliases in question are set up to, for instance, nature curse @target.
Unknown2009-05-03 05:26:54
QUOTE (Aerotan @ May 3 2009, 01:14 AM) <{POST_SNAPBACK}>
apparently, in the time since I have last written a program, I have gone retarded. I'm trying to make an alias so that I can send a value to a variable from the command line.

I want to be able to type in something like x krokani and switch my aliases from targeting oozes to targeting krokani. The aliases in question are set up to, for instance, nature curse @target.

You want to send: nature curse %1
Aerotan2009-05-03 08:43:14
QUOTE (Ried @ May 2 2009, 10:26 PM) <{POST_SNAPBACK}>
You want to send: nature curse %1

No no, like...I want to bind NATURE CURSE @target to a macro, and use an alias to change the "@target" 's value
Raeri2009-05-03 09:19:23
QUOTE (Aerotan @ May 3 2009, 06:43 PM) <{POST_SNAPBACK}>
No no, like...I want to bind NATURE CURSE @target to a macro, and use an alias to change the "@target" 's value


Make an alias for "x *" to send "%1" to the "target" variable?
Aerotan2009-05-03 09:38:10
Ah, that did it...

EDIT: Aaand now I see why that might be a problem. is there a way to have it evaluate a statement before it sends the macro?

EDIT 2, "Tinkering, for the win!": Ah, make it send an alias, got it.