Lua:Class:Stringlist

From Cheat Engine
Revision as of 14:24, 25 June 2026 by Leunsel (talk | contribs) (Major overhaul of the post.)
Jump to navigation Jump to search

{} Class

class Stringlist : Strings

The Stringlist class represents a mutable list of strings.

It inherits from Strings and adds sorting, duplicate handling, and case-sensitivity behavior.

Inheritance

Class Inherits From Description
Stringlist Strings A string list object with sorting and duplicate handling options.
Strings Object Base class for string collection objects.

Creation

<> Lua API Reference

function createStringlist() : Stringlist

Creates a Stringlist class object.

Function Parameters

This function has no parameters.

Returns

Stringlist — The created Stringlist object.

Properties

Property Type Description
Sorted Boolean Determines if the list should be sorted.
Duplicates DuplicatesType Determines how duplicates should be handled when the list is sorted.
CaseSensitive Boolean Determines if the list is case sensitive.

DuplicatesType

Constant Value Description
dupIgnore 0 Ignores duplicate values.
dupAccept 1 Accepts duplicate values.
dupError 2 Raises an error when a duplicate value is added.

Methods

Method Return Type Description
getDuplicates() DuplicatesType Returns the Duplicates property.
setDuplicates(Duplicates) void Sets the Duplicates property. Valid values are dupIgnore, dupAccept, and dupError.
getSorted() Boolean Returns true if the Sorted property is enabled.
setSorted(boolean) void Sets the Sorted property.
getCaseSensitive() Boolean Returns true if the CaseSensitive property is enabled.
setCaseSensitive(boolean) void Sets the CaseSensitive property.

Examples

local list = createStringlist()

list.add("Banana")
list.add("Apple")
list.add("Cherry")

list.Sorted = true

for i = 0, list.Count - 1 do
  print(list[i])
end

list.destroy()
local list = createStringlist()

list.Sorted = true
list.Duplicates = dupIgnore

list.add("Apple")
list.add("Apple")
list.add("Banana")

for i = 0, list.Count - 1 do
  print(list[i])
end

list.destroy()
local list = createStringlist()

list.CaseSensitive = false
list.Sorted = true
list.Duplicates = dupError

list.add("Apple")

local success, err = pcall(function()
  list.add("apple")
end)

if not success then
  print("Duplicate error: " .. tostring(err))
end

list.destroy()

Main Pages

Core Lua documentation entry points

Lua
Script Engine