Difference between revisions of "FormList Pseudocode"

From the CreationKit Wiki
Jump to navigation Jump to search
(Create Page with Glitch's pseudocode)
 
m (Add link to FormList Script)
Line 1: Line 1:
Pseudocode for the FormList by [https://www.nexusmods.com/users/3027732 Glitchfinder], uploaded at their request.<syntaxhighlight lang="c++">
Pseudocode for the [[FormList Script|FormList's Papyrus functions]] by [https://www.nexusmods.com/users/3027732 Glitchfinder], uploaded at their request.<syntaxhighlight lang="c++">
class FormList
class FormList



Revision as of 19:38, 7 March 2022

Pseudocode for the FormList's Papyrus functions by Glitchfinder, uploaded at their request.

class FormList

  OrderedList scriptForms;
  OrderedList pluginForms;

  FormList(OrderedList plugin) {
    scriptForms = new OrderedList();
    pluginForms = plugin;
  }

  void AddForm(Form newForm) {
    if (scriptForms.Contains(newForm))
      return;

    scriptForms.Append(newForm);
  }

  int Find(Form findForm) {
    if (scriptForms.Contains(findForm))
      return scriptForms.IndexOf(findForm);

    if (pluginForms.Contains(findForm))
      return scriptForms.Length + pluginForms.IndexOf(findForm);

    return -1;
  }

  Form GetAt(int formIndex) {
    if (scriptForms.Length > formIndex)
      return scriptForms[formIndex];

    formIndex -= scriptForms.Length;

    if (pluginForms.Length > formIndex)
      return pluginForms[formIndex];

    return None;
  }

  int GetSize() {
    // Untested, therefore, an assumption
    return scriptForms.Length + pluginForms.Length;
  }

  bool HasForm(Form testForm) {
    if (scriptForms.Contains(testForm))
      return true;

    return pluginForms.Contains(testForm);
  }

  void RemoveAddedForm(Form removeForm) {
    scriptForms.Remove(removeForm);
  }

  void Revert() {
    scriptForms.Clear()
  }
}