AIM

MSN

Website URL

ICQ

Yahoo

Jabber

Skype

Location

Interests

I recently dug into scripting and noticed that a lot of information is missing from the docs and wiki.
I thought I would go ahead and list off some problems I ran into as I wrote my first widget.
Shoutouts to MAD_JIHAD and SickDownlink.
Where can I find example scripts?
My first heuristic when diving into a new API or code base is to find examples and see how they work. The two main examples (the fade example, and the basic wiki example, are good but generally geared to the visual aspect of widgetcraft.) However, there are more examples tucked away in
reflexfps\base\internal.pak\internal\ui\widgets\
You'll need to open the .pak with an archive viewer like 7zip, or your unlicensed version of WinRAR. This was extremely useful information that I wish I would have known about! So I highly recommend starting there if you're interested in widgets.
What functions were called by the engine for initialization, updating, and enabling?
This information came from Qualx on the Reflex Discord, people are great there, and I highly recommend poking your head in there if you have any additional questions.
The entire code file is executed immediately when the game loads it. This execution will usually define one or more widgets which will exist persistently, and the game will then call widget:draw() every frame on any visible, registered widgets. It'll also call initialize() on every widget, followed by show() and draw() if the widget will be visible, immediately after loading the file, and before continuing to load other files, iirc.
How does scope work?
I've noticed that if you're attempting to call function that are scoped to your Widget (e.g.: MyWidget:SomeFunction(){} ), you'll need to call it from either MyWidget:draw(), MyWidget:initialize(), or MyWidget:show(). I've also noticed that calling my own functions internally require the self: prefix to reference the objects function. (e.g.: MyWidget:draw(){self:SomeFunction();} ).
How do I setup a variable to modify from the game's command line?
This one was a bit tricky because I needed to change the way I thought about variables. If you want to store a variable for later use, or for use in a console command you'll need to create a variable. This variable is pushed to game.cfg and is persistent. (I believe...) to create a variable, widgetCreateConsoleVariable("myvariablename", "variabletype", 1); where variable type is int, string, float, or any other primitive. Now modifying that variable from the console is a little more interesting. Once you add the variable, you can access it like this: ui_MyWidget_myvariablename 12345678 where 12345678 should represent the type you're trying to modify. Note you can call a console command with consolePerformCommand("bind mousewheeldown UI_MyWidget_MyVariableName DVD");
I hope this helps someone out in the future. If I'm wrong about any of this, let me know.
-Nath (pain][world)

In my config I have lines with comments appended e.g.
bind x weapon 1 // axe
Although the above line somehow works, when checking my binds x is actually bound to 'weapon 1 //axe'
Some other commands are not so lucky:
bind mouse2 loadconfig zoom2 // zoom bind
Which instead lectures me on the correct use of loadconfig.
Right now the only command which fails like this that I've noticed is loadconfig -- other binds and all commands seem to work fine, I suppose because the config filename isn't predefined like other binds are.
Still, it seems fairly sketchy that it's not ignoring it in my weapon binds even though they work anyway.

So I've been trying out this game and it looks good so far, mostly testing some maps alone but I'll get more involved in multi-player soon enough.
I have some problems with the binds, though. When I assign a command to a specific key it doesn't seem to be permanent. I used the console to bind the weapons to my preferred keys but then when I tried to enter a multi-player server, everything seemed to be back to default (except my assigning jump to the right mouse button and my mouse sensitivity settings).
I'm not sure what I'm doing wrong here, if I'm supposed to edit the .cfg file or not, 'cause that's what I tried to do when running the game for the first time (without success), but changing the controls via console seemed to work until I joined a server.
Anyone know what the problem might be or how to fix it?

Server crashing if set wrong map cvar.
Plus, I wanna to see available map list on current server. Like put "map " and u will get this list, or better "map" + double tab or "map" + first map name char (like default console commands).