js,miniwindows Drawing text syntax error

Posted by Dengli on Sat 09 Mar 2013 10:35 AM — 3 posts, 20,655 views.

#0
function ok(){
Note ("Loading constants.js is ok");
eval( Include("D:/Game/Mud/myDoc3-8/plugins/constants.js") );

var win ="test_"+ GetPluginID ()

WindowCreate (win, 0, 0, 180, 80,6,0, ColourNameToRGB("lightblue")) //475,line
WindowRectOp (win, 5, 0, 0, 55, 25, 6,15 + 0x0800)

WindowFont (win, "f", "Trebuchet MS", 28, true, false, false, false)

width = WindowTextWidth (win, "f", "Lazy dog yawns")
height = WindowFontInfo (win, "f", 1)
ascent = WindowFontInfo (win, "f", 2)
descent = WindowFontInfo (win, "f", 3)
leading = WindowFontInfo (win, "f", 4)

WindowText (win, "f",
"Lazy dog yawns",
5, 20, 0, 0,
ColourNameToRGB ("darkgreen"),
false)

WindowShow (win, true)
}


Script Error
The game: Peking knight line MUSHClient4.43 Green Edition
The implementation of 475 rows and 2 columns
Immediate execution
Parameter is Required


Please advise which is why??
Australia Forum Administrator #1
Copying your shown code on its own I find that the error is in line 3:


 eval( Include("D:/Game/Mud/myDoc3-8/plugins/constants.js") );


I'm not familiar with what that does, but I suggest you look it up. If these are the MUSHclient constants you can probably live without them.

Commenting that out, I then get an error (Argument not optional) on this line:


WindowFont (win, "f", "Trebuchet MS", 28, true, false, false, false)


Template:function=WindowFont
WindowFont

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




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


You need two more arguments (Charset and PitchAndFamily).

This is basic stuff. When you get an error message, find the line number, look at what is on that line, and work out what is wrong with it.
Australia Forum Administrator #2
The examples on the Miniwindows documentation use Lua, which allows default arguments, so copying and pasting may not always work. It might be easier to use Lua, unless you really like JScript.