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!
=== Unsetting Bitflags === The last thing we need to cover is how to unset bitflags. I mentioned that anything & 0 = 0, so you can be sure we'll use this. The problem however is that the values we have (disabilities as 0b0110, DISABILITY_EYE, _EAR, _ARM, _LEG) are not really sufficient, since, if we just do a simple & between the disabilities variable and the constant for the disability, it will end up resetting everything else: disabilities = disabilities & DISABILITY_EAR disabilities = 0b0110 & 0b0010 disabilities = 0b0010 This is not what we want. We want the disability we add in to be reset. So we'll need a 0 in place of the disability flag, and a 1 everywhere else. This is because 1 AND anything = anything; at the same time anything AND 0 = 0. So what we have to do is invert the DISABILITY_EAR constant. We do this with the NOT operator: /mob/proc/remove_disability(var/dis) disabilities = disabilities & ~dis So now when we call remove_disability(DISABILITY_EAR) we will get disabilities = disabilities & ~dis disabilities = 0b0110 & ~0b0010 disabilities = 0b0110 & 0b1101 disabilities = 0b0100 In other words, disabilities will now no longer have the DISABILITY_EAR flag set.
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