I'm having trouble creating a custom login script.
I want a script to be run exactly exactly once per connection to a server, and ONLY on the connection to that server.
Maybe I'm using the script or GUI wrong.
Here's how to reproduce what I have so far in my test case.
1) connect to some system
2) Click the Scripts icon
3) Add Group + name it anything
4) Add this as the test code
echo "sysConnectionEvent\n"
5) Add sysConnectionEvent via the above Add User Event Handler (and click the + to do so)
Observed behavior:
Anytime the window is moused over it will echo that text...
Desired behavior:
This text should be printed exactly ONCE during the initial connection.
Trouble with using sysConnectionEvent to create a custom login script.
Re: Trouble with using sysConnectionEvent to create a custom login script.
You need to put your code into a function, not just into the script as-is. Check out https://wiki.mudlet.org/w/Manual:Event_ ... g_an_event for an example
Re: Trouble with using sysConnectionEvent to create a custom login script.
To clarify, you're saying that the entire code is evaluated / re-evaluated every time I mouse back in to the window, including re-registration via the in-script method (hopefully unique/limited to one call of the function)?
How is someone supposed to use the GUI to do that; or does it just not work?
How is someone supposed to use the GUI to do that; or does it just not work?
Re: Trouble with using sysConnectionEvent to create a custom login script.
Yes, the entire script is evaluated every time, but "evaluating" a function simply means that the function is turned into a functioning block of code that can be used, the function itself is not actually executed. But code that isn't contained within a function is executed, which is actually important, because this is frequently used to declare important variables that are necessary for the functions to operate properly. The key is that to make an event handler, you need to make a function with a name that matches the name of your script, and then whenever the appropriate event is raised, that function will be called if you have registered it in the GUI for your script. That function will receive as a first argument the name of the event that is being raised (so that you can tell them apart if you have registered more than one event for that script), followed by whatever arguments have been passed with the event itself.
Here is an example of what you could do to get the login behavior you are looking for:
Here is an example of what you could do to get the login behavior you are looking for:
Re: Trouble with using sysConnectionEvent to create a custom login script.
I'm still having trouble, I know that this evaluates because when I add an echo outside of the function it prints....
However my event handler is never run, and it also doesn't receive any other events.
Does the 'sysConnectionEvent' depend on what mudlet thinks a login is, rather than the LITERAL connection being made?
However my event handler is never run, and it also doesn't receive any other events.
I also added the connectLogin as a 'user event handler' as described above.
Does the 'sysConnectionEvent' depend on what mudlet thinks a login is, rather than the LITERAL connection being made?
Re: Trouble with using sysConnectionEvent to create a custom login script.
That should work just fine, I pasted it into a new script and:
[ INFO ] - Looking up the IP address of server:avalon.mud.de:23 ...
[ INFO ] - The IP address of avalon.mud.de has been found. It is: 91.215.74.15
[ INFO ] - Trying to connect to 91.215.74.15:23 ...
[ INFO ] - A connection has been established successfully.
sysConnectionEventconnect USER PASS
login should be complete
Avalon ist seit ueber 23 Jahren etabliert.
Unverschluesselte Verbindung
Re: Trouble with using sysConnectionEvent to create a custom login script.
That is extremely odd. It /wasn't/ working but actually closing and restarting Mudlet fixed it.
Thank you for the assistance.
Thank you for the assistance.
Re: Trouble with using sysConnectionEvent to create a custom login script.
Interestingly enough, sometimes things happen that way. When Mudlet isn't behaving the way it should, sometimes it is because some things persist in memory but aren't visible in the code you see, but this is resolved when you restart Mudlet (or even just close and then reopen the profile).
Re: Trouble with using sysConnectionEvent to create a custom login script.
Should be fixed but we'd need the steps to reproduce it