ROM

ROM

The ROM chip gives you access to assets through code. These include some built-in assets such as the StandardFont.

Note: Since you can only have one ROM per gadget, it will not have a number after its name in your gadget's list of modules:

gdt.ROM

Properties

ROM contains two main properties, User and System. User gives you access to your own assets added to your gadget through the Multitool, and System accesses the built-in assets. Each one of those two properties have their own tables as such:

Assets {Asset} read only

Returns a table of all assets regardless of type.

SpriteSheets {SpriteSheet} read only

Returns a table of only SpriteSheets.

Codes {Code} read only

Returns a table of only Code assets.

AudioSamples {AudioSample} read only

Returns a table of only AudioSamples.

Examples

Say you have a sprite sheet in your gadget's assets named "Player.png" which contains sprites for a player character. To use it with the VideoChip's DrawSprite method, you would load it like so:

local sheet = gdt.ROM.User.SpriteSheets["Player.png"]

gdt.VideoChip0:DrawSprite(vec2(10,10), sheet, 0, 0, color.white, color.clear)

In this case we are drawing the sprite at the requested SpriteSheet sheet's position 0, 0 onto the Screen position 10, 10, without affecting its tint or transparency.

If you want to print text using the default font, you need to load it like so:

local font = gdt.ROM.System.SpriteSheets["StandardFont"]

gdt.VideoChip0:DrawSprite(vec2(10,10), sheet, "Hello world!", color.white, color.clear)

This will use the StandardFont to print the string "Hello world!" at the screen's position 10, 10, in white color and no background. If you want to make a custom font to use with this function instead, check the font function of the Sprite Editor.