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.
Due to spam on this forum, all posts now need moderator approval.
Entire forum
➜ MUSHclient
➜ VBscript
➜ Room Editor in VBScript
It is now over 60 days since the last post. This thread is closed.
Refresh page
Posted by
| Torgny
Sweden (15 posts) Bio
|
Date
| Thu 30 May 2002 12:06 PM (UTC) |
Message
| Hello,
I want to make a room/text editor in VBScript. On my Macintosh I use a client called Rapscallion, and it has some of the best scripting capabilities around, compared to other MUD clients. Only problem is that I use Windows at work. What I want to do is this:
I want to catch the description from a 'room stat' command output that looks like this:
---
Room name: Artovil's Loft Room
Zone: [ 12], VNum: [ 1297], RNum: [ 505], Type: Ancient Regio
Flux Type: Rich (20), Available Flux: 120
SpecProc: None, Flags: NO_MOB INDOORS ANCIENT
Resources : NOBITS
Ore : 0 ( 0) Gems : 0 ( 0)
Wood : 0 ( 0) Stone : 0 ( 0)
Description:
This roomy little loft space is lined from floor to roof with bookcases.
When you look at the books you see that strange titles in various ancient and
extinct languages adorn their spines. A large brass chandelier casts eerie
shadows upon the spartan furnishings and over the bookcases; which makes the
multitude of gilden letters and leathery surfaces glisten with illusory light.
The sound of soft music can be heard from an unintelligble source, it sounds a
little like an ancient latin monastery chant.
Extra descs: books book tome
Chars present: Artovil(PC)
Contents: a notepad belonging to Artovil, a grand oak desk
Exit west : To: [ 1251], Key: [ 0], Keywrd: None, Type: NOBITS
No exit description.
Script information:
None.
---
Starting from "Description:" I want to catch the text down to "Extra descs:". Currently there is obviously no way to keep catch more than one line with a trigger, am I correct? If I could do that, then I could put it all into a variable I suppose.
So, what I think I would have to do is make a trigger that fires on "^Description:$" and then calls a script that begins catching lines from that line forward, until another trigger fires on "^Extra descs: "
Now to the core of my question: Is it possible to put the caught text into a notepad window, then somehow search for a window close event and send what was in the window to the world again? Please tell me there's a way to do this?
If not, Nick, can you please consider implementing such functionality into a future version of MUSHclient?
I want this out of many reasons, number one, it makes online building so much easier, also, it is excellent for roleplaying with emote/pose since you can edit your entire emote in one nice window and then send it all to the world.
Any constructive input welcome!
Thanks for taking your time to read this rant, and I hope that perhaps I sparked an idea somewhere...
Warmest Regards,
Torgny 'Artovil' Bjers
Implementor, Arcane Realms MUD |
"Eagles may soar, but weasels don't get sucked into jet engines!" | Top |
|
Posted by
| Shadowfyr
USA (1,791 posts) Bio
|
Date
| Reply #1 on Thu 30 May 2002 06:47 PM (UTC) Amended on Thu 30 May 2002 06:48 PM (UTC) by Shadowfyr
|
Message
| Ok.. The script can't catch lines 'if you mean while in the script. I do use something similar for calculation potions I can make and eq repairing that does the capture part though. You are luck in that you have unique identifiers you can match on.
Basically what you have to do is have the first trigger send that first line to your notepad and activate a second trigger like:
sub Startcapture (trigname, output, wildcards)
world.replacenotepad ("Room data", output)
world.enabletrigger "Capture", 1
end sub
The capture trigger should match on * by itself, then call a script that does the following:
sub Capture (trigname, output, wildcards
world.appendtonotepad (Room data", wildcards(1))
if mid(wildcards(1),1,13) = "Extra descs:" then
world.enabletrigger "Capture", 0
world.activatenotepad ("Room data")
end if
end sub
This will capture all the lines including the last one you want, then make the notpad window the active one.
As for the rest.... I think there is a way to send the notepad contents to the world, but I am not 100% sure since I never used it for anything but editing my scripts and that I no longer use it for that either. However this should solve the first part of your problem. ;) | Top |
|
Posted by
| Nick Gammon
Australia (23,140 posts) Bio
Forum Administrator |
Date
| Reply #2 on Fri 31 May 2002 01:21 AM (UTC) |
Message
|
Quote:
So, what I think I would have to do is make a trigger that fires on "^Description:$" and then calls a script that begins catching lines from that line forward, until another trigger fires on "^Extra descs: "
Shadowfyr (and you) are right, you want something like a trigger such as you describe, to enable another trigger that matches on "*", and the second one disables it.
The "*" trigger can append to notepad, or just append to a variable.
Quote:
Now to the core of my question: Is it possible to put the caught text into a notepad window, then somehow search for a window close event and send what was in the window to the world again? Please tell me there's a way to do this?
Shadowfyr's example will do the first bit, and then when you are ready to send it back, use "send to world" in the notepad window (Ctrl+Shift+S). This lets you put in a preamble and postamble, which you probably need (eg. @description here = ).
You can configure the preamble/postamble in the main configuration window, so you don't need to enter them all the time. |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| Torgny
Sweden (15 posts) Bio
|
Date
| Reply #3 on Fri 31 May 2002 07:33 AM (UTC) Amended on Fri 31 May 2002 07:45 AM (UTC) by Torgny
|
Message
| Thank you Shadowfyr and Nick! By the time I got the script working last night I had already tried the ctrl + shift + S deal by a fluke, so I had it working almost right away. This is excellent! :)
Nick, it would be good to be able to change the post/pre-ambles for the send to world through the scripts so that one can make it send as a pose/emote one time, and the next you send to redit or something else, do you know what I mean?
Here's the working versions of the scripts I wrote from Shadowfyr's examples:
'--- start snip (VB Script)
Sub Redit
world.EnableTrigger "redit", 1
world.send "stat room"
End Sub
Sub Startcapture (trigname, output, wildcards)
world.ReplaceNotepad "redit", ""
world.EnableTrigger "Capture", 1
End Sub
Sub Capture (trigname, output, wildcards)
If InStr(1, wildcards(1), "Extra descs:") Or InStr(1, wildcards(1), "Chars present:") Then
world.EnableTrigger "Capture", 0
world.EnableTrigger "redit", 0
world.ActivateNotepad ("redit")
Else
world.AppendToNotepad "redit", wildcards(1) & VbCrLf
End If
End Sub
'--- stop snip
This Requires the following triggers.
The first trigger:
^Description:$
Send: %0
Send to: Variable
Label: redit
Script: StartCapture
Keep Evaluating = True
Regular Expression = True
The second trigger:
*
Send: %0
Send to: Variable
Label: Capture
Script: Capture
Keep Evaluating = True
This works excellently with almost any OasisOLC, as far as I know. All you need to do is set up your send to world to send this as a pre-amble:
---
redit
2
/c
---
And then the post-amble:
---
/s
q
y
---
Notice that you shouldn't use formatting unless you really know that none of what you write has to be just the way it was sent, for instance, if you have a room parser, the /f and /fi might wrap the text and trim trailing newlines, making some of the words meld together when your parser wraps the lines.
All you need to do to activate the script now is to use "/redit" as a command and it loads the editor.
Warm Regards,
/Torgny |
"Eagles may soar, but weasels don't get sucked into jet engines!" | Top |
|
Posted by
| Nick Gammon
Australia (23,140 posts) Bio
Forum Administrator |
Date
| Reply #4 on Fri 31 May 2002 09:59 PM (UTC) |
Message
|
Quote:
Nick, it would be good to be able to change the post/pre-ambles for the send to world through the scripts so that one can make it send as a pose/emote one time, and the next you send to redit or something else, do you know what I mean?
You can do that in version 3.22 onwards by using "world.setalphaoption" in a script. eg.
world.setalphaoption "paste_postamble", "blah blah" |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| Torgny
Sweden (15 posts) Bio
|
Date
| Reply #5 on Sat 01 Jun 2002 08:05 AM (UTC) |
Message
|
Quote: You can do that in version 3.22 onwards by using "world.setalphaoption" in a script. eg.
world.setalphaoption "paste_postamble", "blah blah"
Really? That is excellent! I will start using it as soon as there's a version that actually remembers my window sizes. Ever since the XML support was implemented my window sizes are not saved. If I install 3.21 or 3.22 window sizes are not remembered as soon as I save down the world file. If I reinstall 3.20 and restore my old world files, then it remembers the sizes.
I use Windows 2000 professional at work, and that's where I use MUSHClient. I doubt it has little to do with the registry in this case, I think they're simply not saved down in XML; or they're saved down in a bad format, or; they're not read from disk at load or something. |
"Eagles may soar, but weasels don't get sucked into jet engines!" | Top |
|
Posted by
| Nick Gammon
Australia (23,140 posts) Bio
Forum Administrator |
Date
| Reply #6 on Sat 01 Jun 2002 08:17 AM (UTC) |
Message
| This problem was reported recently and is fixed in v 3.23. |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| Torgny
Sweden (15 posts) Bio
|
Date
| Reply #7 on Sat 01 Jun 2002 08:26 AM (UTC) |
Message
| Excellent! :) I will post a better version of this script then with some extensions to support emote/pose and maybe descriptions of mobiles as well. |
"Eagles may soar, but weasels don't get sucked into jet engines!" | 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.
20,482 views.
It is now over 60 days since the last post. This thread is closed.
Refresh page
top