Jump to content

[Solved] ModuleTestSubject Question


WololoW

Recommended Posts

So when you look at some stock parts from the update, you will find that there is a new Module, ModuleTestSubject.

I was wondering how exactly the environments = 15 argument works in this code here,

MODULE
{
name = ModuleTestSubject

// nowhere: 0, srf: 1, ocean: 2, atmo: 4, space: 8
environments = 15

useStaging = True
useEvent = False
}

As you see, the comment suggests that there are 5 options, but then directly below it, a 6th, not before mentioned, option is chosen.

Basically: What does "environments = 15" do, and why isnt it commented about?

Thanks in advance!

Edited by WololoW
Link to comment
Share on other sites

it's a bit mask ie in binary it is :

00000 = 0

00001 = 1

00010 = 2

00100 = 4

01000 = 8

01111 = 15 = 8 + 4 + 2 + 1

they choose the easy way to do it by considering only power of 2, including 0 (0, 1, 2, 4, 8... 1 = 2^0, 2 = 2^1, ... with ^ power operant) so they can check a bit is set by

if flags & 00001 = srf

(00111 & 00001 = 00001 binary and)

this is far more efficient (space and time) than numeric mask with things like enum or preprocessor constants, depending on language features.

Link to comment
Share on other sites

This thread is quite old. Please consider starting a new thread rather than reviving this one.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   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...