Skip to content

Instantly share code, notes, and snippets.

@Dreomite
Last active September 20, 2018 14:54
Show Gist options
  • Select an option

  • Save Dreomite/6d4d14e62563eb9c7cc24ec8bcbde5ee to your computer and use it in GitHub Desktop.

Select an option

Save Dreomite/6d4d14e62563eb9c7cc24ec8bcbde5ee to your computer and use it in GitHub Desktop.

If you have VSCode (maybe another text editors will do it as well), you can convert your options widgets relatively fast. This instruction works only for old widget definition style (["field"] = value):

  1. Read README file of options mod example (and probably examine _data and _localization files) to understand how new options definition system works.

  2. Move all localizable fields to localization file (text, title, tooltip, unit_text)

  3. Convert show_widget_condition fields to show_widgets of parent dropdown's options.

  4. Now you need to open "replace" tool (Ctrl + H) with regular expressions activated. Next steps will represent pairs of "replace" tool's textboxes.

  5. Remove mod:localize occurrences, if you have any:

mod:localize\((".+?")\)
$1
  1. Remove unused fields show_widget_condition and text
.*\["show_widget_condition"\].*\n
<NOTHING>

.*\["text"\].*\n
<NOTHING>
  1. Replace widget fields' names that were changed:
\["setting_name"\]
["setting_id"]

\["widget_type"\]
["type"]

\["action"\]
["function_name"]
  1. Completely remove ["this_type_of"] formatting for all fields:
([\t\s])\["([^\s]+)"\]
$1$2
  1. Add necessary fields for all keybinds
([\s\t]*)type[\s\t]*=[\s\t]*"keybind",
$1type = "keybind",\n$1keybind_trigger = "pressed",\n$1keybind_type = "function_call",
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment