aseprite/tests/scripts/userdata.lua
David Capello 76a398b162 [lua] Add access to user data properties in Sprite object (aseprite/api#88)
This is a basic implementation where we can only access basic
properties (not maps or vectors yet).
2023-01-02 12:54:37 -03:00

25 lines
639 B
Lua

-- Copyright (C) 2022 Igara Studio S.A.
--
-- This file is released under the terms of the MIT license.
-- Read LICENSE.txt for more information.
do
local spr = Sprite(1, 1)
spr.properties.a = true
spr.properties.b = 1
spr.properties.c = "hi"
spr.properties.d = 2.3
assert(spr.properties.a == true)
assert(spr.properties.b == 1)
assert(spr.properties.c == "hi")
-- TODO we don't have too much precision saving fixed points in properties
assert(math.abs(spr.properties.d - 2.3) < 0.00001)
spr.properties.a = false
assert(spr.properties.a == false)
spr.properties.b = nil
assert(spr.properties.b == nil)
end