Skip to content

Adding Items

Kiminaze edited this page May 1, 2022 · 4 revisions

AddItem(menuId, title, func)

Adds a new default item to the specified menu.

local itemId = ECM:AddItem(menuId, title, function()

end)
Parameter Type Range Description
menuId integer 0 and above The menu this item should be attached to. (always 0 for the default menu)
title string - The name of the item.
func function - The function that should be executed when clicking the item. Can be left as nil for no function.
Returned value Type Range Description
itemId integer 1 and above The item id of the item for referencing.

AddItems(itemList)

Adds a list of default items to the specified menu. Really useful and less resource intensive if adding a lot of similar items at once. E.g. listing many animations in a menu.

local itemList = {
    { menuId, title, func },
    { menuId, title, func },
    { menuId, title, func },
}
local itemIds = ECM:AddItems(itemList)
Parameter Type Range Description
menuId integer 0 and above The menu this item should be attached to. (always 0 for the default menu)
title string - The name of the item.
func function - The function that should be executed when clicking the item. Can be left as nil for no function.
Returned value Type Range Description
itemIds list of integers - The item ids of the items for referencing.

AddTextItem(menuId, title)

Adds a new item to the specified menu that has no interaction.

local itemId = ECM:AddTextItem(menuId, title)
Parameter Type Range Description
menuId integer 0 and above The menu this item should be attached to. (always 0 for the default menu)
title string - The name of the item.
Returned value Type Range Description
itemId integer 1 and above The item id of the item for referencing.

AddCheckboxItem(menuId, title, checked)

Adds an item with a checkbox to the specified menu.

local itemId = ECM:AddCheckboxItem(menuId, title, checked)
Parameter Type Range Description
menuId integer 0 and above The menu this item should be attached to. (always 0 for the default menu)
title string - The name of the item.
checked bool true or false If the checkbox should be checked by default.
Returned value Type Range Description
itemId integer 1 and above The item id of the item for referencing.

AddSpriteItem(menuId, textureDict, textureName)

Adds an item without text and just an image to the specified menu. Images must be supplied via a texture dictionary.

local itemId = ECM:AddSpriteItem(menuId, textureDict, textureName)
Parameter Type Range Description
menuId integer 0 and above The menu this item should be attached to. (always 0 for the default menu)
textureDict string - The name of the texture dictionary with the image.
textureName string - The name of the images texture inside the texture dictionary.
Returned value Type Range Description
itemId integer 1 and above The item id of the item for referencing.

Clone this wiki locally