Jump to content
Main menu
Main menu
move to sidebar
hide
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
/VM/station wiki
Search
Search
Log in
Personal tools
Log in
Pages for logged out editors
learn more
Contributions
Talk
Editing
Binary flags
(section)
Page
Discussion
English
Read
Edit
View history
Tools
Tools
move to sidebar
hide
Actions
Read
Edit
View history
General
What links here
Related changes
Special pages
Page information
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
=== Setting a bitflag === Above we did the following: var/f = 255 //0b11111111 v3 = c & f What happened was that completely irrespective of what c was, v3 became 0b11111111, since anything OR 1 = 1. But we don't have to have the entire row of ones. What if we just add a single 1 in there. After all 0 OR anything = anything. The 0 doesn't change the value. So let's write a proc, where ''dis'' is the disability we want to add (DISABILITY_EYE, DISABILITY_EAR, etc): mob/proc/add_disability(var/dis) disabilities = disabilities | dis So if disabilities were 0b0000 before we called it, and we called it with DISABILITY_EAR, which is 2, we would get the following calculation calling M.add_disability(DISABILITY_EAR) disabilities = 0b0000 | 0b0010 0b0000 OR 0b0010 = 0b0010 So the ''disabilities'' variable now becomes 0010, which indicates it has the poor hearing disability. But what if we called the same proc again, with the same argument DISABILITY_EAR, would anything change? calling M.add_disability(DISABILITY_EAR) disabilities = 0b0010 | 0b0010 0b0010 OR 0b0010 = 0b0010 Nope. It remains the same, as it should. And if we want to add another leg disability (DISABILITY_LEG)? calling M.add_disability(DISABILITY_LEG) disabilities = 0b0010 | 0b0100 0b0010 OR 0b0100 = 0b0110 The old ear disability remains untouched, and the new leg disability is added.
Summary:
Please note that all contributions to /VM/station wiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
/VM/station wiki:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Toggle limited content width