aseprite / docs

Aseprite documentation
https://www.aseprite.org/docs/
25 stars 56 forks source link

`Palette.getColor()` requires `(Palette, Index)` arguments, not `(index)` #44

Closed Arecher closed 1 month ago

Arecher commented 1 month ago

It's incorrectly stated in the documentation here: https://www.aseprite.org/api/palette#palettegetcolor

I presume it's a recent change, due to all the mentions about Palettes becoming frame based in the future.

When using

local mypalette = app.sprite.palettes[1]
app.fgColor = mypalette.getColor(1)

I got the error that it expected a PaletteObject, not an index on the first argument. image

However, this did work:

local mypalette = app.sprite.palettes[1]
app.fgColor = mypalette.getColor(mypalette, 1)
dacap commented 1 month ago

Hi @Arecher, check that Palette:getColor() is documented as Palette:getColor() and not as Palette.getColor(). Which means that you have to use the function with :, in practice using mypalette:getColor(1) on Lua is exactly as you discovered, it's like calling mypalette.getColor(mypalette, 1).

Arecher commented 1 month ago

You're completely right, my bad! I mess up the : and . all the time, but usually it just tells me that that function/variable doesn't exist, so the fact that they both exist threw me off! Thanks for the clarification!