Register forum user name Search FAQ

Gammon Forum

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 ➜ General ➜ world event script question

world event script question

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


Posted by Guest1   USA  (256 posts)
Date Tue 11 Jul 2006 02:43 AM (UTC)

Amended on Tue 11 Jul 2006 02:56 AM (UTC) by Guest1

Message
Hey. Using v3.75. I have a sub that is run when the world is opened (Shift+Ctrl+6 and in the 'World Events' input boxes) ..when the world is opened it calls a sub called, wait for it, 'world_open'. The sub is used to generate and resize some notepad windows, resize the main MC window, and resize the world window. This is the sub:

sub world_open
   MoveMainWindow -1, -1, 1024, 741
   world.SendToNotepad "STATUS", "status window generated.."
   NotepadFont "STATUS", "WhiteRabbit", 9, 0, 0
   NotepadColour "STATUS", "#FAEBD7", "#000000"
   MoveNotepadWindow "STATUS", 690, 0, 322, 335
   world.SendToNotepad "GROUPSTATUS", "group status window generated.."
   NotepadFont "GROUPSTATUS", "WhiteRabbit", 9, 0, 0
   NotepadColour "GROUPSTATUS", "#FAEBD7", "#000000"
   MoveNotepadWindow "GROUPSTATUS", 690, 335, 322, 198
   world.SendToNotepad "TELLS", "tells window generated.."
   NotepadFont "TELLS", "Verdana", 8, 0, 0
   NotepadColour "TELLS", "#FAEBD7", "#000000"
   MoveNotepadWindow "TELLS", 690, 533, 322, 140
   MoveWorldWindow 0, 0, 690, 673
   world.activate
end sub


Everything works except the resize of the world window itself.. it retains whatever size it was at last time it was closed, and the above sub does not alter it..

If I create another sub on world connect instead of world open, for example:

sub world_resize
   MoveWorldWindow 0, 0, 690, 673
end sub


that works, but I want to use that world connect option for something else. I even tried adding a world.DoAfterSpecial into the world_open sub above, eg:

  world.DoAfterSpecial 1, "world_resize", 12


but nothing.. it seems world.DoAfterSpecial only runs when connected to a world.. any suggestions?
Top

Posted by Nick Gammon   Australia  (23,120 posts)  Bio   Forum Administrator
Date Reply #1 on Tue 11 Jul 2006 03:16 AM (UTC)
Message
Ah, yes I have. :)

If you look at your timer list you will see your timer sitting there, because the world is disconnected, and it doesn't fire on disconnected worlds.

You need to make a timer that fires even if the world is disconnected. Unfortunately a straight DoAfterSpecial won't work, as that doesn't give you the option of doing that. This worked for me (Lua version):


function world_resize ()
 MoveWorldWindow (0, 0, 690, 673)
end -- world_open

function world_open ()
 AddTimer ("resize_my_world", 0, 0, 1, "world_resize ()", 5 + 32, "")
 SetTimerOption ("resize_my_world", "send_to", 12)
end -- world_open


I have added a timer named "resize_my_world" with flags:


  • 1 - enabled
  • 4 - one shot
  • 32 - active when closed


Then I used SetTimerOption to force the send_to field to be 12 (script).

I suspect your original problem is caused by the order in which things are being done internally in MUSHclient. I think the "on document open" is being called before the part which remembers where you last positioned the world window.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Nick Gammon   Australia  (23,120 posts)  Bio   Forum Administrator
Date Reply #2 on Tue 11 Jul 2006 03:18 AM (UTC)
Message
You could save the extra function by simply doing the resize directly on the timer:


function world_open ()
 AddTimer ("resize_my_world", 0, 0, 1, "MoveWorldWindow (0, 0, 690, 673)", 5 + 32, "")
 SetTimerOption ("resize_my_world", "send_to", 12)
end -- world_open


- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Nick Gammon   Australia  (23,120 posts)  Bio   Forum Administrator
Date Reply #3 on Tue 11 Jul 2006 03:25 AM (UTC)
Message
Or, use ImportXML, which is particularly easy in Lua because of multi-line strings:


function world_open () 
ImportXML [[
<timers>
  <timer 
   name="resize_my_world" 
   enabled="y" 
   second="1.00"    
   send_to="12"
   one_shot="y" 
   active_closed="y" >
  <send>MoveWorldWindow (0, 0, 690, 673)</send>
  </timer>
</timers>
]]
end -- world_open


- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Guest1   USA  (256 posts)
Date Reply #4 on Tue 11 Jul 2006 03:31 AM (UTC)
Message
thanks :) except all my scripts are in VB.. so can I still use one of these options alright?
Top

Posted by Nick Gammon   Australia  (23,120 posts)  Bio   Forum Administrator
Date Reply #5 on Tue 11 Jul 2006 03:34 AM (UTC)
Message
Sure, the VBscript version would be:


Sub world_open

'
'  your other stuff here ...
'

   AddTimer "resize_my_world", 0, 0, 1, "MoveWorldWindow 0, 0, 690, 673", 5 + 32, ""
   SetTimerOption "resize_my_world", "send_to", 12
End Sub


- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Guest1   USA  (256 posts)
Date Reply #6 on Tue 11 Jul 2006 03:39 AM (UTC)

Amended on Tue 11 Jul 2006 03:51 AM (UTC) by Guest1

Message
YAY that did it, thanks :)

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.


17,649 views.

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

Go to topic:           Search the forum


[Go to top] top

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