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".
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.
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.
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.
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
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.
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.
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.