Roblox / tarmac

Command line tool to manage Roblox assets
MIT License
115 stars 25 forks source link

Support codegen into larger units #7

Closed LPGhatguy closed 4 years ago

LPGhatguy commented 4 years ago

Right now, the plan is to imitate the semantics that tools in the JS ecosystem have for dealing with assets, where we can pretend to import asset files like they're modules:

local CancelIcon = require(Assets.CancelIcon)
local ConfirmIcon = require(Assets.ConfirmIcon)

cancelBox.Texture = CancelIcon
confirmBox.Texture = ConfirmIcon

We do this by generating Lua files next to each asset that we want to be able to import:

Assets/
├─ CancelIcon.png
├─ CancelIcon.lua
├─ ConfirmIcon.png
└─ ConfirmIcon.lua

Another approach would might want to support is grouping together the generated code into one or more batches of files containing assets keyed by name:

local Assets = require(Assets)

cancelBox.Texture = Assets.CancelIcon
confirmBox.Texture = Assets.ConfirmIcon

With a corresponding directory structure:

Assets/
├─ CancelIcon.png
├─ ConfirmIcon.png
└─ init.lua

The configuration for a project like this might include this bit in its tarmac.toml:

[[inputs]]
glob = "Assets/**/*.png"
codegen = { type = "batch-asset-url", output = "Assets/init.lua" }
LPGhatguy commented 4 years ago

After trying to take up Tarmac on a particularly large internal Roblox project (UIBlox), I think it's pretty clear that one script per image doesn't scale well at all. When updating images, diffs are huge!