# Reading a Sprite Material Constant

**URL:** <https://forum.defold.com/t/reading-a-sprite-material-constant/69188>\
**Category:** Questions\
**Created:** [August 31, 2021, 8:32pm UTC](https://forum.defold.com/t/reading-a-sprite-material-constant/69188 "2021-08-31T20:32:29Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Xorcist](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/xorcist/32/22146_2.png) [@Xorcist](https://forum.defold.com/u/Xorcist)\
**Post date:** [August 31, 2021, 8:32pm UTC](https://forum.defold.com/t/reading-a-sprite-material-constant/69188/1 "2021-08-31T20:32:29Z")

</div>

I have a game object containing a sprite node, whose tint I change on creation (via a factory) like this:

sprite.set\_constant(‘#sprite’, ‘tint’, myVec4)

but for the life of me, I can’t figure out how to read this value at a later time.

Can someone assist me in that capacity?

---

<div class="post-metadata">

**Author:** ![roccosaienz](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/roccosaienz/32/19991_2.png) [@roccosaienz](https://forum.defold.com/u/roccosaienz)\
**Post date:** [August 31, 2021, 9:10pm UTC](https://forum.defold.com/t/reading-a-sprite-material-constant/69188/2 "2021-08-31T21:10:54Z")

</div>

Could you store the tint somewhere in self and then use it later? Or probably you already have it there if you passed the tint as a property at factory creation time?

But probably I am missing something…

---

<div class="post-metadata">

**Author:** ![britzl](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/britzl/32/23_2.png) [@britzl](https://forum.defold.com/u/britzl)\
**Post date:** [August 31, 2021, 9:17pm UTC](https://forum.defold.com/t/reading-a-sprite-material-constant/69188/3 "2021-08-31T21:17:25Z")

</div>

> [@Xorcist](#):
>
> sprite.set\_constant(’#sprite’, ‘tint’, myVec4)
> 
> but for the life of me, I can’t figure out how to read this value at a later time.

My guess was that you could use:

```lua
-- recommended instead of sprite.set_constant() as it is a deprecated function
go.set("#sprite", "tint", vmath.vector4(1,1,0,1))

-- read it next frame
print(go.get("#sprite", "tint"))

```

But for some reason go.get() will give me the original value. I don’t recall why that is. @JCash probably knows!

---

<div class="post-metadata">

**Author:** ![bob\_dev](https://forum-defold.b-cdn.net/letter_avatar_proxy/v4/letter/b/6f9a4e/32.png) [@bob\_dev](https://forum.defold.com/u/bob_dev)\
**Post date:** [May 4, 2024, 8:58pm UTC](https://forum.defold.com/t/reading-a-sprite-material-constant/69188/4 "2024-05-04T20:58:08Z")

</div>

If I spawn a sprite from factory, use go.set(sprite, “tint”, col)  
and destroy it each frame, the memory used by defold keeps increasing. It only happens with tint, so I think that may be related to getting the unexpected value back.

If you do it enough you can see it’s a memory leak still. I made an issue on github for it.
