Scripts and reconnecting.

Posted by Shadowfyr on Sun 04 Nov 2001 01:08 AM — 10 posts, 25,662 views.

USA #0
This started in a different forum, but I took your advice about creating an auto reconnect script, instead of relying on the one in the menu. Ran into a problem though.

I have a start script which on connecting sets 2 variables. One to turn off my quit script (so I don't accidently disconnect). And one to turn on the auto-reconnect.

The problem is that when the mud reboots, the client pops up an alert. If you do not click on it immediately, the client tries to run the start script, then when you do click OK, crashes with a scripting error that terminates the program. It only happens when the alert is shown. I haven't looked to see if this alert can simply be turned off or not yet, but will as soon as I finish posting this.
USA #1
Ok. Here are the actually scripts and associated aliases, etc. As well as the sequence of events leading to the error.

>On World.Connect: Start

sub Start
  world.setvariable "QuitSW", "OFF"
  world.setvariable "AReconnect", "ON"
end sub

>On World.Disconnect: Terminate

sub Terminate
  if world.getvariable ("AReconnect") = "ON" then
    world.connect
  end if
end sub

>Alias: quit
> Script: Quitit

sub Quitit (AliasName, Output, Wildcards)
  if world.getvariable ("QuitSW") = "ON" then
    world.setvariable "AReconnect", "OFF"
    world.send "xyzzq"

      ^----- NOTE: Aliased mud side as quit. Since I have had aliases execute a different alias. I.E. Aliasing xyzzy = quit tends to cause the quit = " " to execute after the client is shut down and restarted, but not the first time using the new alias, odd...

  else
    world.note "Quit is OFF"
  end if
end sub

>Alias: setquit *
> Script: SetQuit

sub SetQuit (AliasName, Output, Wildcards)
  select case Wildcards(1)
  case "ON"
    world.setvariable "QuitSW","ON"
    world.note "Quit is ON"
  case "on"
    world.setvariable "QuitSW","ON"
    world.note "Quit is ON"
  case "OFF"
    world.setvariable "QuitSW","OFF"
    world.note "Quit is OFF"
  case "off"
    world.setvariable "QuitSW","OFF"
    world.note "Quit is OFF"
  case "status"
    world.note "Quit is currently " & world.getvariable("QuitSW")
  case else
    world.note "Error: - Must be ON or OFF"
  end select
end sub

>Alias: recon *
> Script: SetRecon

sub SetRecon (AliasName, Output, Wildcards)
  select case Wildcards(1)
  case "ON"
    world.setvariable "AReconnect","ON"
    world.note "Client will now Reconnect on Disconnect"
  case "on"
    world.setvariable "AReconnect","ON"
    world.note "Client will now Reconnect on Disconnect"
  case "OFF"
    world.setvariable "AReconnect","OFF"
    world.note "Reconnect on Disconnect OFF"
  case "off"
    world.setvariable "AReconnect","OFF"
    world.note "Reconnect on Disconnect OFF"
  case "status"
    world.note "Reconnect on Disconnect is currently " & world.getvariable("AReconnect")
  case else
    world.note "Error: - Must be ON or OFF"
  end select
end sub


<Sequence>
Connect commands:
  Connect
  Send Name
  Send Password
  Send Y - In case this is to reconnect a dropped link.
  Send motd - Message of the day.
  send lwho - See whos on.

Start script executes.
...
Playing
...
Reboot - Remote server diconnects.
Mushclient Alert displayed.
-Terminate script executes and calls World.Connect
-Connect commands repeated.
-Start script called.
-Page Fault and program shuts down.

or

-Terminate script executes and calls World.Connect
-Hit OK before connect commands repeat.
-Connect commands repeat.
-Start script executes.
-Everthing is fine.


Needless to say the first version of these events (with the alert still active) is not very useful... ;)
Amended on Sun 04 Nov 2001 06:47 AM by Shadowfyr
Australia Forum Administrator #2
I would guess you have hit a bug caused by the sequence of events. Probably what happens when you are disconnected is that scripting is shut down (by the client) and then when it tries to run the disconnect script it crashes. I am guessing right now, but it will be something like that.

I'll take a look at that for the next version.
USA #3
Hmm. Not quite. The termination script (I.E. disconnect script) does execute, since it has to call 'World.Connect' to reconnect to the mud. Otherwise it would crash before the mud reconnected and the client began sending the user name, password and other stuff needed to log in. So the problem may not be with scripting being shut down, it may be that the client is temporarily suspending scripting when alert messages are displayed or something. Of course I am not sure how your code works, the alert dialog may be a sign that the client has 'completed' the disconnect, in which case, since the client hadn't 'disconnected' when the Terminate script executed the scripting would still be active, until just before/after the dialog displays... Definitely an interesting glitch in any case. ;)
Amended on Mon 05 Nov 2001 04:09 AM by Shadowfyr
Australia Forum Administrator #4
The alert you mentioned in the first message of this thread ... is that this one?


The connection to (mud) is not open. Attempt to reconnect?

USA #5
No. It is something like, 'Remote host (Ages of Despair) has severed the connection'.... Not sure exactly, but it is the one that comes up whenever I log off instead of simply dropping link, etc.

Also, as I said, login occures normally, user name, password, etc. are entered. All other commands execute and everything looks ok, until you try to click on OK. If you do so before all the commands execute and you are left with just a prompt (I.E. when the initial game screen comes up and asks for the password, to the moment the lwho command is executed) everything works. If you wait too long and all the commands are processed by the mud before hitting OK, it causes a page fault. Since this only happens when using World.connect from the termination script I assume it means that your client is sending all the commands in 'General - Connecting - Connect Text', then tries to call the script 'Start', once that happens clicking on OK will cause a crash.
Amended on Mon 05 Nov 2001 06:22 AM by Shadowfyr
USA #6
Almost had it right. The actual alert message is>

The 'Ages of Despair" server has closed the connection.

or at least real close to that. I hit OK before remembering I needed to write it down. lol
USA #7
Also just noticed today. When that particular dialog is shown, the task bar icon that you click to connect/disconnect remains down until you close the dialog. Is it possible that the client is shuting down the specific world and does not complete the task till the dialog is closed. Since a normal auto-reconnect bypasses the dialog, an error would never occure. However, if the dialog displays prior to finishing all the tasks to complete a disconnect it is possible that one of those tasks frees memory or something needed by the script.

I assume that vbscript acts like a COM object in this case, using the clients namespace/memory to execute. So releasing this memory when the dialog closes would leave one or more processes without the objects they intended to link/call.
Australia Forum Administrator #8
Go to the Global Configuration, and uncheck "Notify me when connection broken".
Australia Forum Administrator #9
Also, version 3.19 allows you to eliminated the "unable to connect" message, fixes a problem with auto-reconnected, and allows you to have timers that fire when disconnected.