NS2 Autocomplete Parameters

NS2 Autocomplete Parameters

Export Function Autocomplete


NS2 Autocomplete Parameters image 1

NS2 supports autocompletion for user scripts. The documentation that this feature even exists is...lacking at best (I found a reference to the AutocompleteData interface[github.com] and had to search the git repository to find out how to actually use it).

Here's a simple example.

export function autocomplete(autocompleteData, flags) { return autocompleteData.servers; }

This code will autocomplete for all of the game's servers.

The AutocompleteData provides a list of all servers, local files (scripts and txt separately), and has a flags() method which takes in a flags schema the same way ns.flags() does, and that method has better documentation[github.com] , including examples.

Return type is simply a list of strings and the game will filter for relevant strings automatically.

The flags parameter is an array of the current parameters list when pressing tab (eg. "run autocompletetest.js icarus net"+tab would pass ["icarus","net"] to the autocomplete method) which is useful for determining which parameter is currently being auto-completed. eg. the scp command takes a file name then a server name.

And that's basically it.

Source: https://steamcommunity.com/sharedfiles/filedetails/?id=2876503029					

More Bitburner guilds