I just learned what a function is 10minutes ago. Who wants to help! :)

Posted by ReallyCurious on Sat 07 Apr 2007 01:19 AM — 23 posts, 87,645 views.

USA #0
This is the BEST client I've seen!

I'm going to have multiple connections to a mud with MC and I want to create an 'auto assist' type thing for some of the windows. In my old client I'd just trigger something like "$assistvariableguy massacres" = assist, etc and then make an alias #alias {autto %1} {#var assistvariableguy %1}. And all I had to do was type 'autto warrior' and my char would assist always. It worked fine but it assists even when it's already assisting and I want to fix that.

This is a typical round when I'm in combat and don't need to assist:

358H 137V 1X 0C [Me:Perfect] [Warrior:Fair] [a shadow:Awful] Mem:3>
A shadow hits Warrior hard.
Warrior massacres a shadow with his slash.
You miss a shadow with your pierce.
358H 137V 1X 0C [Me:Perfect] [Warrior:V.Bad] [a shadow:Awful] Mem:3>

And if I were out of combat and need to assist:

358H 137V 1X 0C Mem:2>
A shadow hits Warrior hard.
Warrior massacres a shadow with his slash.
358H 137V 1X 0C Mem:2>

I want to know if it's possible to do something similar to what i had for all character windows I want. So, I'd like to still be able to type 'autto Steve' or something like that and the multiple character windows i want to assist will assist.

Thanks!
Australia Forum Administrator #1
Well, to get you started, to send commands to another connection you need to (script) a call to GetWorld to get the "other" world, and then send commands to that world. See:

http://www.gammon.com.au/scripts/doc.php?function=GetWorld

A simple example (I'm not going to work out exactly what you are trying to do) would be:


<aliases>
  <alias
   match="assist *"
   enabled="y"
   send_to="12"
   sequence="100"
  >
  <send>
otherguy = assert (GetWorld ("otherguy"), 
                   "otherguy not open")  -- get world

assert (otherguy:IsConnected(), 
        "otherguy is not connected") -- check connected

otherguy:Send ("kick %1")  -- send command

</send>
  </alias>
</aliases>


This example assumes the world name for your alternate character is called "otherguy". The first thing it does is get a world obejct, and raises an error if not.

Then it checks that world is connected to the MUD.

Finally it sends a command (with Send) to that world.
USA #2
Thanks for the reply!

Is what I'm trying to do complicated? Or maybe it's just alot of work? :) I've been perusing this forum for the last few hours and I've been looking at lua and jscript and then back to lua tutorials too :) All while refreshing this site waiting for a response!

Hey, quick question. And it might be a little stupid.

Why doesn't every line start at the left margin? Is there any reason to that? Or is it just more aesthetically pleasing this way? :)
Australia Forum Administrator #3
Like this?


otherguy = assert (GetWorld ("otherguy"), 
                   "otherguy not open")  -- get world


I just did that to fit it into the forum better. It could have been written:


otherguy = assert (GetWorld ("otherguy"), "otherguy not open")  -- get world


As for your basic idea, it sounds simple enough. I suggest you try breaking it down into steps and trying them out - you will learn more that way than just having someone else do it.

Your first task is to make the "autto" alias, which simply sets a variable. This is easy enough, one of the options in aliases is to set a variable. Try making that first, and then experiment with using that variable to do the actual assisting.

You will get a better response if you try to do something, and then post your attempts, rather than just roughly describing what you want and waiting for someone to write it. See this post for how to post your existing triggers / aliases:

http://www.gammon.com.au/forum/?id=4776
USA #4
Most of the time those indentations are used for legibility. The first way this helps is by allowing the eye to follow where parts of the code is separated. ex:

if weapontype == dagger then
if class == thief then
Send("backstab %1")
else
Send("attack %1")
end
else
Send("bash %1")
end


if weapontype == dagger then
  if class == thief then
    Send("backstab %1")
  else
    Send("attack %1")
  end
else
  Send("bash %1")
end

The second block of code is much easier to read than the first one because you can follow where the if/else/end statements line up.

The second reason for some of the indentations is that frequently a line of code will not fit into a screen easily, much like in Nick's example. In certain languages, there are options to allow the code to continue into the next line of the text file so you don't have to keep scrolling back and forth. I'm very used to old text editors which could only show 80 characters, so I will occasionally be neurotic about making all my lines 80 characters or less.
USA #5
I have a few unrelated questions...

I want to be able to set aliases/triggers/variables/highlights/subs etc through the command line.

I want my previous command to not disappear after I hit enter but stay in the command line so I can hit us it again.

Can I do that?

Also, I noticed that if I have multiple connections to a mud if 1 of those connections gets disconnected due to a lag timeout, all of my connections get disconnected. Is this typical? Is there any way to resolve it?

Thanks :)

p.s. Thanks for the help you guys. This is definitely not my strong suit but I'm trying to learn.
Amended on Sat 07 Apr 2007 11:12 AM by ReallyCurious
USA #6
For all of these questions, I'll assume that you have Lua as your scripting language since this is the Lua board in the forum. Most of your answers can be found in the list of all inbuilt script functions here: http://www.gammon.com.au/scripts/function.php

Variables is the easy one.
MC varialbes: /SetVariable( "varname", "value" )
Lua variables: /foo = bar

Adding aliases, and triggers are done through the AddAlias and the AddTrigger functions. Links to the explanations of those functions can be found in the page listed above, and you can search the forums for the function names to get an extensive list of help for those functions. Gags, subs, and highlights are just triggers that affect the output lines.

For leaving a command in the commandline after it's been sent, press alt-0 to pop up the game-input-command config menu, and check the "Autorepeat command" checkbox.
USA #7
Forgot about one section... If by a lag timeout you mean that there is an issue with the connection between your computer and the mud server, then yes. All the connections will use the same pathways (usually), so if you cannot connect with one session, the others will have the same problem.

If by lag timeout, you mean that you haven't given the mud any input for a long time, so it disconnects you for inactivity, then that's a bit odd. I've never used MUSHclient to open up more than one connection to the same server before, so I can only theorize why that would happen. The easy way around that would be to set up a timer to send a carriage return every 10 minutes, or however long you feel like sending it. That way the mud knows you're still there. On the mud I play on, they send a message that you're being sucked into the void due to inactivity, so I just have MUSHclient send some text to bring me back.
Australia Forum Administrator #8
Quote:

I want to be able to set aliases/triggers/variables/highlights/subs etc through the command line.


Yes, you can use AddTrigger etc. to do that, it could be a little tedious - the GUI interface is readily available.

You can always make an alias that does a shortened version of AddTrigger, if you want to make a command-line version, and just accept the things you think you would want.


Quote:

Also, I noticed that if I have multiple connections to a mud if 1 of those connections gets disconnected due to a lag timeout, all of my connections get disconnected. Is this typical? Is there any way to resolve it?


This shouldn't happen unless your router itself is disconnecting you, in which case I would expect all connections to drop.
USA #9
I think I got what I was looking for with using a handful of variables/triggers/aliases and the getworld alias you pasted. But, I'm not doing a lot of things correctly.

question 1:

<aliases>
<alias
match="autto *"
enabled="y"
send_to="12"
sequence="100"
>
<send>world2 = assert (GetWorld ("world2"),
"world2 not open") -- get world

assert (world2:IsConnected(),
"world2 is not connected") -- check connected

world2:Send ("asist %1")
</send>
</alias>
</aliases>

I want to set a variable in world2.

world2:Send ("SetVariable ("assister1", "%1")") didn't work. I tried to use a trigger in world2 to create the variables that way:

<triggers>
<trigger
enabled="y"
match="asist *"
send_to="1"
sequence="100"
>
<send>SetVariable ("assister", "%1")
SetVariable ("assister2", "%1")</send>
</trigger>
</triggers>

question 2:

<triggers>
<trigger
enabled="y"
match="assister misses"
send_to="10"
sequence="100"
>
<send>Assist
SetVariable ("assister", "adfsfdsfs")</send> -- change variable so I'm not spamming assist.
</trigger>
</triggers>

How do I make this trigger recognize the value of variable "assister"?

<triggers>
<trigger
enabled="y"
match="is dead! R.I.P."
sequence="100"
>
<send>SetVariable ("assister","GetVariable("assister2")")</send> -- Trying to set variable back to what it just was after mob death so I assist again.
</trigger>
</triggers>

Still not sure on how to use getvariable properly.



USA #10
oh ya the connection issue was my router. forgot to mention that.
USA #11
Quote:
world2:Send ("SetVariable ("assister1", "%1")")


ok that ought to be...

world2:SetVariable("assister1", "%1")


The Send command is for sending something to the connected mud, not to the WORLD itself, the 'world2:' is responsible for sending it to the WORLD.

and

Quote:
<triggers>
<trigger
enabled="y"
match="assister misses"
send_to="10"
sequence="100"
>
<send>Assist
SetVariable ("assister", "adfsfdsfs")</send> -- change variable so I'm not spamming assist.
</trigger>
</triggers>


SHOULD be something like...

<triggers>
<trigger
enabled="y"
match="@assister misses"  <--Add @ infront of Variable Name
expand_variables="y"      <--ADD THIS LINE! Not this comment
send_to="10"
sequence="100"
>
<send>Assist
SetVariable ("assister", "adfsfdsfs")</send>
</trigger>
</triggers>


and

Quote:
<send>SetVariable ("assister","GetVariable("assister2")")


you are using too many double quotes, you do not need to quote COMMANDS such as GetVariable, but you DO need to quote text that is sent into that command, ie. the "assister2", this is what that line ought to be ...

<send>SetVariable ("assister",GetVariable("assister2"))


Hope that solves your problems for the time being.


Amended on Sun 08 Apr 2007 10:56 AM by Onoitsu2
USA #12
Thanks.

The alias is working now. The "* is dead! R.I.P." works now.

"*@assister1 misses" works to assist but SetVariable ("assister1", "kdfjskfjsf") isn't.

How can I fix the setvariable?
Amended on Sun 08 Apr 2007 05:39 PM by ReallyCurious
Australia Forum Administrator #13
In what way? Can you post the whole alias? The snippets I see above are a bit worrying:


<send>Assist
SetVariable ("assister", "adfsfdsfs")</send>


What is that word "Assist" on its own? That isn't a script command.
USA #14
<triggers>
<trigger
enabled="y"
expand_variables="y"
match="@assister1 misses *"
sequence="100"
>
<send>assist
SetVariable ("assister1", "kdfjskfjsf")</send>
</trigger>
</triggers>

I want it to execute assist one time and then change "assister1" variable so it doesn't keep assisting every combat round.
USA #15
is assist a function, or an alias? If it's a function, then it needs to be assist(). If it's an alias, then it needs to be Execute( "assist" ). If it's a mud command, then Send( "assist" ).
USA #16
thanks Shaun. works now.

Yea it was a mud command. I'm still very used to using simple triggers from my old client, "#action {you are hungry} {eat food}" for example.

Does this way seem too sloppy? Is there something else I should be doing here?

Here is the end result:

World1.

<aliases>
<alias
match="autto *"
enabled="y"
send_to="12"
sequence="100"
>
<send>world2 = assert (GetWorld ("world2"),
"world2 not open") -- get world

assert (world2:IsConnected(),
"world2 is not connected") -- check connected
world2:SetVariable("assister1", "%1")
world2:SetVariable("assister2", "%1")</send>
</alias>
</aliases>

World2:

<triggers>
<trigger
enabled="y"
match="*is dead! R.I.P."
send_to="12"
sequence="100"
>
<send>SetVariable ("assister1",GetVariable("assister2"))</send>

</trigger>
<trigger
enabled="y"
expand_variables="y"
match="@assister1 misses *"
send_to="12"
sequence="100"
>
<send>Send ("assist")
SetVariable ("assister1", "kdfjskfjsf")</send>
</trigger>
</triggers>

Amended on Mon 09 Apr 2007 02:22 AM by ReallyCurious
Australia Forum Administrator #17
Quote:

I'm still very used to using simple triggers from my old client, "#action {you are hungry} {eat food}" for example.


You can easily make an alias to do just that:


<aliases>
  <alias
   match="#action {*} {*}"
   enabled="y"
   send_to="12"
   sequence="100"
  >
  <send>

require "addxml"  -- addxml extension

-- add the trigger 

addxml.trigger {  
  match = "%1", 
  send = "%2",
  sequence = 100,
  enabled = true,
               }

ColourNote ("white", "green", "Added trigger to match on '%1', sending '%2'")
</send>
  </alias>
</aliases>






Now if I type:


#action {you are hungry} {eat food}


I see echoed:


Added trigger to match on 'you are hungry', sending 'eat food'


And, this trigger is now added to the trigger list:


<triggers>
  <trigger
   enabled="y"
   match="you are hungry"
   sequence="100"
  >
  <send>eat food</send>
  </trigger>
</triggers>

Amended on Wed 18 Apr 2007 10:30 PM by Nick Gammon
USA #18
niiiiiiice
Australia Forum Administrator #19
You know what a really strange thing is?

On the zMUD forum, there is a posting from Reallycurious, entitled "I just learned what a function is 10minutes ago. Who wants to help! :)" - and it reads:

Quote:

I'm going to have multiple connections to a mud and I want to create an 'auto assist' type thing for some of the windows. In my old client I'd just trigger something like "$assistvariableguy massacres" = assist, etc and then make an alias #alias {autto %1} {#var assistvariableguy %1}.


Are you posting exactly the same question on all the client forums?

Here is the link:

http://forums.zuggsoft.com/phpbb/viewtopic.php?t=27001
USA #20
Sure, I did post 'almost' the same question on the zmud forum, but there was 1 difference I didn't mention on zmud forum.

I'm shopping for a new mud client and I want to make sure whichever one I commit to is going to be the right choice for me(support/functionality).

I probably wouldn't have even found MUSHclient if the latest zmud 7.21 didn't cause a code4 error and crash immediately when i ran it. So I asked my friends in irc for what I should do and I got 3 suggestions: dl an earlier version of zmud/dl MUSHclient(i never heard of it)/dont bother switching your client.

Now it's been about a week since I've been using mushclient and I'm liking it a lot. I think the forum support here has been great these last few days too. I don't see myself switching to zmud...

On another note, I'm going to try and get a rescue script and heal script working with LUA with both of them being accessable from other worlds. I'll be posting those soon :)
Australia Forum Administrator #21
I'm glad you like it, and look forwards to seeing your scripts posted here. :)
USA #22
I too tried to install zMud, not planning on switching, would not over my own dead body either, but wanted to attempt to make conversions from zmud a ton easier for myself. I failed miserably with v7.21 due to the same crash error, and just used an older version, 6.16 in fact. I am attempting to determine the DB formatting, whether it is using SOME standard system, or a system all its own, because IF it is a standard system, then that is a step in the right direction for a mapper, or at least using maps made using zMud :)

Laterzzz,
Onoitsu2