PICO-8 Wiki
Advertisement
fget( n, [f] )
Gets the value of a flag of a sprite.
n
The sprite number.

f
The flag index (0-7). If omitted, a bit field of all flags is returned.

Each sprite has eight flags that can be set in the sprite editor or by the fset() function. You can use these flags for any purpose. One possible purpose is to define "layers" of map tiles, which modifies the behavior of the map() function.

Flags are numbered from 0 to 7, appearing left to right in the sprite editor.

When fget() is called without a flag index, it returns a number that represents all of the flags. This is a bit field where flag 0 is the "least significant" bit: flag 0 (leftmost) has a value of 1, flag 1 has a value of 2, flag 2 has a value of 4, and so on, up to flag 7 with a value of 128.

Examples[]

Given a sprite with flags 0, 1, and 7 set:

first = fget(16, 0)   -- true
second = fget(16, 1)  -- true
third = fget(16, 2)   -- false
eighth = fget(16, 7)  -- true

flags = fget(16)      -- 131 (1 + 2 + 128)
Sprite flags. Image from jelpi.p8 by zep.

See also[]

Advertisement