×

To be able to write in the forum you need to authenticate. Meanwhile it's read-only.

Re: What's the point of attributes_unset_(1|2|3)?

What's the point of attributes_unset_(1|2|3)?
February 20, 2023 11:17PM
From what I can tell, attributes_unset_(1|2|3) is always nil. What is this field for?
Re: What's the point of attributes_unset_(1|2|3)?
March 02, 2023 01:50AM
I believe those fields are for the negative attributes. It's in the same format as the positive attributes (attributes_set_[1/2/3]), being an integer where each bit corresponds to one of the attributes.
Re: What's the point of attributes_unset_(1|2|3)?
April 04, 2023 05:43PM
When you're calling 'GetFinds', you need to include 'attributes_unset' in the fields (along with 'attributes_set').

I have a set of C+P functions that I use frequently - here's the one I use for attributes, if it's helpful.

---------------------------------------------------------------------------------------
-- Attributes
---------------------------------------------------------------------------------------

-- Given a bit index, get the value if that bit was set to 1
-- e.g. given 4, set the fourth bit from the right to 1. Result: 8
function bit(p)
return 2 ^ (p - 1) -- 1-based indexing
end

-- Given a bitfield and bitmask, AND the two to determine if the bitmask is set in this field.
function hasbit(x, p)
return x % (p + p) >= p
end

function rshift(x, by)
return math.floor(x / 2 ^by )
end

function find_has_attribute(find, attribute)
local setindex = rshift((attribute-1) % 96, 5)+1
local bitindex = ((attribute-1) % 32)+1
local attributeset = (attribute <= 96 and "attributes_set_" or "attributes_unset_") .. setindex
local cmp = (value or true)
return cmp == hasbit(find[attributeset], bit(bitindex))
end
Re: What's the point of attributes_unset_(1|2|3)?
April 04, 2023 07:15PM
Thank you both for your replies!

The small sample of my finds that I looked at must not have had any negative attributes, since the field(s) were all zero. Clearly that was inadequate -- however, on closer inspection, I see how the fields are used.

(Inspired by bmuzzin's latest series, I just set up https://project-gc.com/Challenges//76415 for fun.)
Sorry, you do not have permission to post/reply in this forum.