Skip to main content

Getting Items

How do you actually connect your ModScript to a MemeItem? You use one of these functions:

Get Current Item

To get the MememItem that the ModScript is attached to, you can use the getCurrentItem function in your script:

registerType("SpriteRenderer")
local datBoi = getCurrentItem()
local datBoiSpriteRenderer = datBoi.GetComponent("SpriteRenderer")
datBoiSpriteRenderer.flipX = true

getCurrentItem returns the GameObject of the retrieved MemeItem.

Get Item By ID

There are times where you might want to access a different MemeItem to that of the attached ModScript. This can be done by using getItemById and passing its unique item ID as an argument:

registerType("TMPro.TMP_Text") -- TextMeshPro is weird, u gotta register like this. TMP_Text is the base type of all TextMeshPro components, apply similar logic to other erroring things in the future ig.
local chargeTheyPhone = getItemById("AllTheyKnowIsChargeTheyPhone-388114-933a")
local chargeTheyPhoneText = chargeTheyPhone.GetComponent("TMPro.TMP_Text")
chargeTheyPhoneText.text = "reeeeeeepeeepeeepoopoo."

To get this unique item ID, you can copy it by pressing the copy icon next to the ID at the top of the Level Builder UI:

The MemeId here is OpenNanoor and the unique item ID is OpenNanoor-596493-1369.

Get Items By Meme ID

There may also be times where you want to do something to multiple MemeItems of a certain meme type. You can do this by using the getItemsByMemeId function and passing the MemeId:

registerType("Vector3")
local chads = getItemsByMemeId("Chad")
for i, chad in ipairs(chads) do -- make all their right arms tiny
local chadArm = chad.transform.Find("Chad/bone_1/bone_2/bone_11") -- transform is a special type that comes pre-registered so you don't have to :0
chadArm.transform.localScale = chadArm.transform.localScale * 0.420
end

You can find this MemeId by copying the first part of the MemeItem's unique ID, which is explained above.

getItemsByMemeId returns a List (auto-converted to a Lua table) of all the MemeItems in your level that match that type. You can loop through and filter them and do as you please.


tip

To keep a nice smooth framerate, it is important you cache as much as you can.

Caching just means storing the result of an operation so it doesn't have to recalculate every time if it doesn't need to. Just store the result of getting an item into a variable, as shown above. More is discussed in the performance section.