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

Gammon Software Solutions forum

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

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  General
. . -> [Subject]  world event script question

Home  |  Users  |  Search  |  FAQ
Username:
Register forum user name
Password:
Forgotten password?

world event script question

[Reply to this subject]  Reply to this subject   [New subject]  Start a new subject   [Refresh] Refresh page


Posted by Demonsurfer   USA  (256 posts)  [Biography] bio
Date Tue 11 Jul 2006 02:43 AM (UTC)  quote  ]

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

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?
[Go to top] top

Posted by Nick Gammon   Australia  (18,772 posts)  [Biography] bio   Forum Administrator
Date Reply #1 on Tue 11 Jul 2006 03:16 AM (UTC)  quote  ]
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
[Go to top] top

Posted by Nick Gammon   Australia  (18,772 posts)  [Biography] bio   Forum Administrator
Date Reply #2 on Tue 11 Jul 2006 03:18 AM (UTC)  quote  ]
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
[Go to top] top

Posted by Nick Gammon   Australia  (18,772 posts)  [Biography] bio   Forum Administrator
Date Reply #3 on Tue 11 Jul 2006 03:25 AM (UTC)  quote  ]
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
[Go to top] top

Posted by Demonsurfer   USA  (256 posts)  [Biography] bio
Date Reply #4 on Tue 11 Jul 2006 03:31 AM (UTC)  quote  ]
Message
thanks :) except all my scripts are in VB.. so can I still use one of these options alright?
[Go to top] top

Posted by Nick Gammon   Australia  (18,772 posts)  [Biography] bio   Forum Administrator
Date Reply #5 on Tue 11 Jul 2006 03:34 AM (UTC)  quote  ]
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
[Go to top] top

Posted by Demonsurfer   USA  (256 posts)  [Biography] bio
Date Reply #6 on Tue 11 Jul 2006 03:39 AM (UTC)  quote  ]

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

Message
YAY that did it, thanks :)

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


2,090 views.

[Reply to this subject]  Reply to this subject   [New subject]  Start a new subject   [Refresh] Refresh page

Go to topic:           Search the forum


[Go to top] top

[Home]

Written by Nick Gammon - 5K

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

[Best viewed with any browser - 2K]    [Internet Contents Rating Association (ICRA) - 2K]    [Web site powered by FutureQuest.Net]