Skip to content

hazzard993/love-inline-import

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

love-inline-import

A TypeScriptToLua plugin that in-lines image imports.

How to use

Add the plugin

yarn add -D love-inline-import
# or npm install -D love-inline-import

Register the plugin in your tsconfig.json

{
  "tstl": {
    "luaPlugins": [
      { "name": "love-inline-import" }
    ]
  }
}

Tell TypeScript that a png import returns an Image type

// add this ambient code to a file within your project
// this tells TypeScript that imports ending with .png
// are expected to return an image type
declare module "*.png" {
  import { Image } from "love.graphics";
  const image: Image;
  export = image;
}

And you're good to go! Here's some sample input and output code

import * as player from "./player.png";

love.draw = () => {
  love.graphics.draw(player);
};
local player = love.graphics.newImage(...) -- ... is generated and contains image data

love.draw = function()
  love.graphics.draw(player)
end

Features

  • Allows images to be stored in your source directory
  • Image resolution is handled on compilation

About

A TypeScriptToLua plugin that in-lines image imports

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published