[Home] [Downloads] [Search] [Help/forum]

Gammon Forum

See www.mushclient.com/spam for dealing with forum spam. Please read the MUSHclient FAQ!

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  General
. . -> [Subject]  OnConnect
Home  |  Users  |  Search  |  FAQ
Username:
Register forum user name
Password:
Forgotten password?

OnConnect

It is now over 60 days since the last post. This thread is closed.     [Refresh] Refresh page


Posted by Katie Love   (19 posts)  [Biography] bio
Date Fri 16 Jan 2009 08:01 PM (UTC)
Message
I have a bunch of variables I would like reset on connect. Is there a way I can trigger an alias or script when I connect to a mud? It seems like something easy that should be documented but I've been trying and I can't seem to find the information.

Thanks!!!
[Go to top] top

Posted by WillFa   USA  (525 posts)  [Biography] bio
Date Reply #1 on Fri 16 Jan 2009 08:19 PM (UTC)

Amended on Fri 16 Jan 2009 08:21 PM (UTC) by WillFa

Message
Go to the Scripting... Preferences (CTRL+SHIFT+6)

And fill in the names of Script functions into any World Events that you want. :)
[Go to top] top

Posted by Katie Love   (19 posts)  [Biography] bio
Date Reply #2 on Sat 17 Jan 2009 04:14 AM (UTC)
Message
Thanks!

It's working now -- but...

Every time I seem to make a change to my aliases/triggers/etc it is dropping the script file and I'm having to reload it. It must be a setting somewhere. It's really annoying to have to reload it all the time.

Anyone experience this?
[Go to top] top

Posted by Nick Gammon   Australia  (21,323 posts)  [Biography] bio   Forum Administrator
Date Reply #3 on Sat 17 Jan 2009 05:08 AM (UTC)
Message
What do you mean by "dropping the script file"?

Normally simply changing an alias should not affect the current script file.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Katie Love   (19 posts)  [Biography] bio
Date Reply #4 on Thu 19 Feb 2009 09:10 PM (UTC)
Message
Since it looks like I have to move at least one alias into a script, I figured I should resurrect this thread.

The error message I get can be found here: http://imagebin.ca/view/szC-x6ml.html

The error message appears everytime I hit "ok" or "cancel" on the Configuration window (the window where I can add aliases, macros, scripts, varaible, etc)

My Achaea.lua file contains the following:
function OnConnect (name, line, wildcards)
SetVariable("Connecting", "1")
end -- function

The only other relevant piece I can thing of is in the configuration window, under World Events. A screenshot of that is here: http://imagebin.ca/view/SMGGew.html

Thanks!!!
[Go to top] top

Posted by Nick Gammon   Australia  (21,323 posts)  [Biography] bio   Forum Administrator
Date Reply #5 on Thu 19 Feb 2009 09:30 PM (UTC)
Message
Can you show the whole scripting configuration window, not just the bottom bit?

Anyway, the OnConnect function does not take arguments (name, line, wildcards: only apply to aliases and triggers). However that won't matter under Lua.



- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Katie Love   (19 posts)  [Biography] bio
Date Reply #6 on Fri 20 Feb 2009 03:50 AM (UTC)
Message
The entire window is here: http://imagebin.ca/view/VeNPn5LK.html

I've tried multiple combinations of things. Rather frustrated right now :-(...
[Go to top] top

Posted by Nick Gammon   Australia  (21,323 posts)  [Biography] bio   Forum Administrator
Date Reply #7 on Fri 20 Feb 2009 04:17 AM (UTC)

Amended on Fri 20 Feb 2009 04:18 AM (UTC) by Nick Gammon

Message
I can't really explain it. I tried myself and the OnConnect worked fine.

The only things I can think of are:


  • Some subtle spelling problem, where an "oh" is a zero somewhere. Try copying and pasting the OnConnect word from the script configuration to the script file to make sure.

  • The script file you pasted is not in fact the one referenced in the script configuration (that is, you have two Achaea.lua files). Try hitting the Edit button in the script configuration to confirm that the correct file actually opens.


BTW - what version of MUSHclient are you using?

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Katie Love   (19 posts)  [Biography] bio
Date Reply #8 on Fri 20 Feb 2009 05:13 PM (UTC)
Message
I'm running MUSHclient 4.37.

Sadly, I have thought of both of those things and tried them. They didn't work. I actually just tried them again for giggles and it still didn't work.

I would love to move some things into the script file -- in fact i'm about to create a recursive funciton, which would need the script file. I've tried reinstalling as well.

I can't shake the feeling it's some small thing, but I can't figure out what.
[Go to top] top

Posted by Katie Love   (19 posts)  [Biography] bio
Date Reply #9 on Fri 20 Feb 2009 05:23 PM (UTC)
Message
** Update **

I changed the function name from OnConnect to Foo and it *appears* to be working. I've been trying to get the error to pop up again with no success.

Of course, I'll want to do some scripting for a bit before i'm 100% sure this worked. Is it possible OnConnect is some sort of reserved word?
[Go to top] top

Posted by Nick Gammon   Australia  (21,323 posts)  [Biography] bio   Forum Administrator
Date Reply #10 on Sat 21 Feb 2009 01:27 AM (UTC)
Message
No it isn't.

My only explanation now is that your script file is perhaps larger than the 3 lines you posted, and that somehow you change the OnConnect variable to something else. For example:


function OnConnect ()
print "connected"
end -- OnConnect

--- 500 lines of code here ...

OnConnect = {}


Now that code gives the error message "The world connect subroutine named "OnConnect" could not be found." - this is because OnConnect is now a table and not a function.

One thing you could try is, after processing the script file, and seeing the error message, go into the immediate window and type:


print (type (OnConnect))


After mucking up the script file (as above) it printed "table".

It should be "function". Or maybe it would print "nil".


- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] 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.


6,137 views.

It is now over 60 days since the last post. This thread is closed.     [Refresh] Refresh page

Go to topic:           Search the forum


[Go to top] top

Quick links: MUSHclient. MUSHclient help. Forum shortcuts. Posting templates. Lua modules. Lua documentation.

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.

[Home]


Written by Nick Gammon - 5K   profile for Nick Gammon on Stack Exchange, a network of free, community-driven Q&A sites   Marriage equality

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( https://gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Hosted at FutureQuest]