Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are
spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the
password reset link.
Entire forum
➜ MUSHclient
➜ Lua
➜ I just learned what a function is 10minutes ago. Who wants to help! :)
I just learned what a function is 10minutes ago. Who wants to help! :)
|
Posting of new messages is disabled at present.
Refresh page
Pages: 1 2
Posted by
| ReallyCurious
USA (50 posts) Bio
|
Date
| Sat 07 Apr 2007 01:19 AM (UTC) |
Message
| 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!
| Top |
|
Posted by
| Nick Gammon
Australia (23,122 posts) Bio
Forum Administrator |
Date
| Reply #1 on Sat 07 Apr 2007 04:12 AM (UTC) |
Message
| 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. |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| ReallyCurious
USA (50 posts) Bio
|
Date
| Reply #2 on Sat 07 Apr 2007 04:24 AM (UTC) |
Message
| 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? :) | Top |
|
Posted by
| Nick Gammon
Australia (23,122 posts) Bio
Forum Administrator |
Date
| Reply #3 on Sat 07 Apr 2007 04:35 AM (UTC) |
Message
| 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
|
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| Shaun Biggs
USA (644 posts) Bio
|
Date
| Reply #4 on Sat 07 Apr 2007 06:41 AM (UTC) |
Message
| 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. |
It is much easier to fight for one's ideals than to live up to them. | Top |
|
Posted by
| ReallyCurious
USA (50 posts) Bio
|
Date
| Reply #5 on Sat 07 Apr 2007 11:07 AM (UTC) Amended on Sat 07 Apr 2007 11:12 AM (UTC) by ReallyCurious
|
Message
| 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. | Top |
|
Posted by
| Shaun Biggs
USA (644 posts) Bio
|
Date
| Reply #6 on Sat 07 Apr 2007 06:07 PM (UTC) |
Message
| 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. |
It is much easier to fight for one's ideals than to live up to them. | Top |
|
Posted by
| Shaun Biggs
USA (644 posts) Bio
|
Date
| Reply #7 on Sat 07 Apr 2007 06:14 PM (UTC) |
Message
| 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. |
It is much easier to fight for one's ideals than to live up to them. | Top |
|
Posted by
| Nick Gammon
Australia (23,122 posts) Bio
Forum Administrator |
Date
| Reply #8 on Sat 07 Apr 2007 09:00 PM (UTC) |
Message
|
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. |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| ReallyCurious
USA (50 posts) Bio
|
Date
| Reply #9 on Sun 08 Apr 2007 09:50 AM (UTC) |
Message
| 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.
| Top |
|
Posted by
| ReallyCurious
USA (50 posts) Bio
|
Date
| Reply #10 on Sun 08 Apr 2007 09:53 AM (UTC) |
Message
| oh ya the connection issue was my router. forgot to mention that. | Top |
|
Posted by
| Onoitsu2
USA (248 posts) Bio
|
Date
| Reply #11 on Sun 08 Apr 2007 10:46 AM (UTC) Amended on Sun 08 Apr 2007 10:56 AM (UTC) by Onoitsu2
|
Message
|
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.
| Top |
|
Posted by
| ReallyCurious
USA (50 posts) Bio
|
Date
| Reply #12 on Sun 08 Apr 2007 12:09 PM (UTC) Amended on Sun 08 Apr 2007 05:39 PM (UTC) by ReallyCurious
|
Message
| 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?
| Top |
|
Posted by
| Nick Gammon
Australia (23,122 posts) Bio
Forum Administrator |
Date
| Reply #13 on Sun 08 Apr 2007 08:45 PM (UTC) |
Message
| 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.
|
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| ReallyCurious
USA (50 posts) Bio
|
Date
| Reply #14 on Mon 09 Apr 2007 01:07 AM (UTC) |
Message
| <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. | Top |
|
The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).
To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.
60,579 views.
This is page 1, subject is 2 pages long: 1 2
Posting of new messages is disabled at present.
Refresh page
top