Jump to content
  • 0

Q> On Bitmask


PsyOps

Question


  • Group:  Members
  • Topic Count:  6
  • Topics Per Day:  0.00
  • Content Count:  150
  • Reputation:   11
  • Joined:  12/03/18
  • Last Seen:  

 

	//   1: Reward 1 | 2: Reward 2 | 4: Reward 3
	// Sets Basic List of Rewards
	.RewardList = 1|2|4;

In this example, the variable .RewardList = 7;

Is there a way to detect how many rewards are there on this variable using bitmask?
 

Link to comment
Share on other sites

5 answers to this question

Recommended Posts

  • 0

  • Group:  Forum Moderator
  • Topic Count:  93
  • Topics Per Day:  0.02
  • Content Count:  10013
  • Reputation:   2348
  • Joined:  10/28/11
  • Last Seen:  

On 1/24/2024 at 9:54 PM, PsyOps said:

Is there an existing script_command that will allow me to produce the value '2' as it includes reward 1 and 2.

that's not how bitmask work.

dont want it work this way? then change the whole thing, and not to use bitmask.

 

.RewardList = 1|2; // include only reward 1 and 2

using bitmask, this is the way to get reward 1 and 2.

 

  • Upvote 1
Link to comment
Share on other sites

  • 0

  • Group:  Forum Moderator
  • Topic Count:  93
  • Topics Per Day:  0.02
  • Content Count:  10013
  • Reputation:   2348
  • Joined:  10/28/11
  • Last Seen:  

3 rewards.

.RewardList = 1; // include only reward 1
.RewardList = 1|2; // include only reward 1 and 2
.RewardList = 1|4; // include only reward 1 and 3
.RewardList = 2|4; // include only reward 1 and 3
.RewardList = 2|4; // include only reward 2 and 3
.RewardList = 4; // include only reward 3

 

  • Upvote 1
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  6
  • Topics Per Day:  0.00
  • Content Count:  150
  • Reputation:   11
  • Joined:  12/03/18
  • Last Seen:  

Probably my question needs to be rephrased.

Lets say that the value of the .RewardList = 3;

Is there an existing script_command that will allow me to produce the value '2' as it includes reward 1 and 2.

its kind of like getting the array size of the bitmask value.

I hope i am asking it right but thanks @Emistry for the reply.

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  5
  • Topics Per Day:  0.00
  • Content Count:  211
  • Reputation:   17
  • Joined:  12/23/11
  • Last Seen:  

set .@valve,0;

if (.@options & 1)    .@valve++;
if (.@options & 2)    .@valve++;
if (.@options & 4)    .@valve++;

mes .@valve;

 

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  6
  • Topics Per Day:  0.00
  • Content Count:  150
  • Reputation:   11
  • Joined:  12/03/18
  • Last Seen:  

Thanks for the answer @Emistry.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...