Windows form element?

Posted by Ashass on Sun 28 Nov 2010 03:53 AM — 23 posts, 100,591 views.

#0
Is it possible to create any windows that pop up, similar to an MS Access form? Doesn't have to be exactly that of course. Pondering things like launching a web page [local] that has custom asp scripting, that's good for some stuff, but really I'd like to just have a simple form that I can track status effects, draw a mini map of the area I'm in, or push directional arrows to move that direction (think numpad movement, but gui format.)

This could eventually lead into more complex actions, such as clicking somewhere on a displayed map, and issuing a speedwalk trigger to move to said room.
Australia Forum Administrator #1
Not forms that you fill in, but miniwindows do a lot of that:

Template:post=10346
Please see the forum thread: http://gammon.com.au/forum/?id=10346.


If you want to ask questions and get responses, switch to Lua and then you get various utilities that let you pop up dialog boxes (although VBscript has some of those too).
#2
This is pretty much what I've been trying to find, thanks Nick. I'll look into the syntax more in the morning, gotten some basic windows shown / text etc.

Are the instances of windows automatically deleted when you close the client - but save the world details? Or do you have to manually destroy each window created?
USA #3
The "windows" are really drawn directly onto MUSHclient's output window; they're not OS-provided or -owned. When MUSHclient closes, the miniwindows disappear, and the client starts again without any miniwindows. (This isn't a problem, because plugins just create their miniwindows when they're loaded.)
#4
Trying to actually write text, and every time I do, I get errors. lots and lots-

This causes an issue

15*:   WindowText win, "Status", "test", 5, 5, 0, 0, "blue"


and this


  15 :   WindowText win, "f", "Quest Log", 0
  16*:             5, 10, 0, 0,
  17 :             ColourNameToRGB ("blue"), 
  18 :             false


and this



WindowText win, "Status", "test", 5, 5, 0, 0


Oddly, this doesn't error [but it also doesn't do anything I can see]


WindowText win, "Status", "test", 0,0,0,0,0,0



[EDIT]

Here's the context:

sub createstatus (strAliasName, strOutput, arrWildCards)
  world.WindowCreate "Status", 0, 0, 400, 800, 6, 0, world.ColourNameToRGB("white")
  WindowFont win, "Status", "Trebuchet MS", 12, TRUE, FALSE, FALSE, FALSE, 0, 0
end sub

sub showstatus (strAliasName, strOutput, arrWildCards)
  WindowShow "Status", true
end sub

sub hidestatus (strAliasName, strOutput, arrWildCards)
  WindowShow "Status", false
end sub

sub writetext (strAliasName, strOutput, arrWildCards)
   WindowText win, "Status", "test", 0,0,0,0,0,0          
end sub
Amended on Sun 28 Nov 2010 07:29 AM by Ashass
USA #5
What errors?

[EDIT]: Oh, and you're missing a comma in your second example.
Amended on Sun 28 Nov 2010 07:11 AM by Twisol
#6
Script error
World: DSL
Execution of line 15 column 39
Immediate execution
Syntax error
Line in error: 
  WindowText win, "f", "Quest Log", 0,
Error context in script:
  11 :   WindowShow "Status", false
  12 : end sub
  13 : 
  14 : sub writetext (strAliasName, strOutput, arrWildCards)
  15*:   WindowText win, "f", "Quest Log", 0,
  16 :              5, 10, 0, 0,
  17 :              ColourNameToRGB ("blue"), 
  18 :              false
  19 : end sub
#7
Changing it all to one line (instead of multiline like the sample) results in this:

Script error
World: DSL
Execution of line 15 column 3
Function/Sub: writetext called by alias
Reason: processing alias "writetext"
Wrong number of arguments or invalid property assignment: 'WindowText'
Error context in script:
  11 :   WindowShow "Status", false
  12 : end sub
  13 : 
  14 : sub writetext (strAliasName, strOutput, arrWildCards)
  15*:   WindowText win, "Status", "Quest Log", 0, 5, 10, 0, 0,ColourNameToRGB ("blue"), false
  16 : end sub
  17 : 
  18 : sub mssqlconn (strAliasName, strOutput, arrWildCards)
  19 :   Dim UserDB
USA #8
I'm not too familiar with VBscript, but there are two things you might want to try.

1) Put it on a single line. A recent issue had to do with formatting, so it can't hurt to try.

2) Put parentheses around the arguments. I know VBscript has a weird sub/function distinction, but it can't hurt to try either.
#9
WindowText win, "Status", "Quest Log", 0, 5, 10, 0, 0,ColourNameToRGB ("blue"), false


is now

WindowText win, "Status", "Quest Log", 5, 10, 0, 0,ColourNameToRGB ("blue"), false


No error, but no text actually shows.
Amended on Sun 28 Nov 2010 07:33 AM by Ashass
USA #10
Add a WindowShow win, true call right after that. MUSHclient doesn't redraw the output window until text comes in or Redraw, WindowShow, or one other I forget is called.
Amended on Sun 28 Nov 2010 07:34 AM by Twisol
#11
Yeah... that did nothing =P

The window is already shown, so i have a white palette, but no text appears on that palette.
Australia Forum Administrator #12

WindowFont win, "Status", "Trebuchet MS", 12, TRUE, FALSE, FALSE, FALSE, 0, 0


Is "Status" the font or the window? You really need a font name (eg. "f") and a window name.
USA #13
I know it's already shown, the point was to refresh the view. Which apparently didn't work.

Try Note'ing the return value from WindowText (and WindowFont). If anything's not 0, go to the errors list [1] and find what it means.

[1] http://www.gammon.com.au/scripts/function.php?action=errors
#14
Status is the window, 'f' is the font.

world.WindowCreate "Status", 0, 0, 400, 800, 6, 0, world.ColourNameToRGB("white")
  WindowFont win, "f", "Trebuchet MS", 12, TRUE, FALSE, FALSE, FALSE, 0, 0


So how does that translate into windowtext?
USA #15
Where do you define win?
#16
I don't exactly know what win is, it was a default from the example code. On a side note, how would I note the return value of writetext?
USA #17
'win' is supposed to be a variable you create that contains the name of your window. Since it's undefined, your calls don't do anything, because there's no window to do things to.

[EDIT]: Probably the below, though I don't know how function composition affects parentheses usage in VBscript.
Note WindowText (...)
Amended on Sun 28 Nov 2010 07:54 AM by Twisol
#18
sub createstatus (strAliasName, strOutput, arrWildCards)
  world.WindowCreate "Status", 0, 0, 400, 800, 6, 0, world.ColourNameToRGB("white")
  WindowFont "Status", "f", "Trebuchet MS", 12, TRUE, FALSE, FALSE, FALSE, 0, 0
end sub

sub showstatus (strAliasName, strOutput, arrWildCards)
  WindowShow "Status", true
end sub

sub hidestatus (strAliasName, strOutput, arrWildCards)
  WindowShow "Status", false
end sub

sub writetext (strAliasName, strOutput, arrWildCards)
  WindowText "Status", "f", "Quest Log", 5, 1, 0, 0,ColourNameToRGB ("blue"), false
  WindowShow "Status", true
end sub


This now shows 'Quest Log' in blue font - that was the issue (font not having the window defined)

Preciate the quick help!


Nick, may I suggest, instead of win, maybe change it to "window name" in your samples so it's a little more intuitive?

Ah well! Nice job Twisol!
USA #19
Glad I could help! :)
Australia Forum Administrator #20
Ashass said:

Nick, may I suggest, instead of win, maybe change it to "window name" in your samples so it's a little more intuitive?


Glad you got it working.

I hope you are reading the help files, I usually read them myself, and I wrote the stuff:

Template:function=WindowFont
WindowFont

The documentation for the WindowFont script function is available online. It is also in the MUSHclient help file.



In there, it makes it clear that the first argument is the window name:


Prototype

long WindowFont(BSTR WindowName, BSTR FontId, BSTR FontName, double Size, BOOL Bold, BOOL Italic, BOOL Underline, BOOL Strikeout, short Charset, short PitchAndFamily);


It also says "WindowName - the name of an existing miniwindow.".

Virtually every miniwindow function needs a window name, this lets you have multiple windows at once. For example "inventory", "chat".

Also it suggests that you append the plugin ID so that the window names are unique between plugins. So for example:


win = "inventory_" & PluginID   ' VBscript
win = "inventory_" .. PluginID () -- Lua


This means the actual window name might be "inventory_21448b31e497a95a36ee5173".

I just used "win" to save typing.

It is useful to use the function-name completion in MUSHclient. Even if you do it in the command window and copy and paste into your script. For example, typing "windowfo" and then hitting Shift+Tab you see offered a menu with WindowFont / WindowFontInfo / WindowFontList.

Choose WindowFont and it gives you the correct spelling and capitalization, and suggests the arguments:


WindowFont ( WindowName , FontId , FontName , Size , Bold , Italic , Underline , Strikeout , Charset , PitchAndFamily )


Now all you have to do is replace words like "WindowName" with, well, the window name.
#21
I don't use any third party plugins, should I be writing this as a plugin, instead of just as a vbscript file (that I reference in the scripts section?)

Does it matter one way or the other? -- Should I put the windows into separate boxes, instead of drawing it all out in a single box?

Looking for 'best practices' if you will, since I'm brand new to the mini windows idea.
Australia Forum Administrator #22
It's easier ultimately to have a plugin. Plugins handle various callbacks in a more natural way.

Plus you can then just easily add them to multiple world files (eg. if you have multiple characters).

I would use separate windows (boxes) for different things, eg. inventory, stats, etc. - if that is what you meant.