Search the Community

Showing results for tags 'variable'.



More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Public Forums
    • Announcements
    • General Chatter
    • Tournaments
    • Mapping forum
    • UI Scripting
    • Trading
    • Support
    • Bugs
    • Silver Screen

Found 1 result

  1. 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)