ID:476872
 
(See the best response by DarkCampainger.)
Code:
turf
var
Oxygen = 60
CarbonDioxide = 90
Nitrogen = 6
NormalCarbonDioxide = 2
NormalNitrogen = 78
NormalOxygen = 20

New()
..()
MaintainAtmosphere()

proc
MaintainAtmosphere()
while(1==1)
{
if(Oxygen > NormalOxygen)

Oxygen -= 0.50;
sleep(25);

else if(Oxygen < NormalOxygen)

Oxygen += 0.50;
sleep(25);

else

Oxygen += (rand(-1,1));
sleep(25);

if(Nitrogen > NormalNitrogen)

Nitrogen -= 0.50;
sleep(25);

else if(Nitrogen < NormalNitrogen)

Nitrogen += 0.50;
sleep(25);

else

Nitrogen += (rand(-1,1));
sleep(25);

if(CarbonDioxide > NormalCarbonDioxide)

CarbonDioxide -= 0.50;
sleep(25);

else if(CarbonDioxide < NormalCarbonDioxide)

CarbonDioxide += 0.50;
sleep(25);
else

CarbonDioxide += (rand(-1,1));
sleep(25);
sleep(10)
world << "[CarbonDioxide], [Oxygen], [Nitrogen]"
}


Problem description:
Well, i am trying to test this system out but i'm not sure how/what should i use to output the values of the turfs. If you have anything that simplify this then please post your opinion, I'll take it into consideration.
Best response
For a basic test, you could use Click() to output the values of each individual turf.

You could also throw together some bars and display them in each turf's overlays to see the levels all at once.

If you've played with the latest beta, you could try the new maptext support and add some text overlays to display each value. Or you could use DmiFontsPlus.
If you were looking for something a little shorter you could try this, not sure if it work though.
//sorry forgot to add notes in MaintainGas() current is the
//current value for the gas and normal is the normall value
//for the gas.

turf
var
Oxygen = 60
CarbonDioxide = 90
Nitrogen = 6
NormalCarbonDioxide = 2
NormalNitrogen = 78
NormalOxygen = 20

New()
..()
while(src)
src.MaintainGas(src.Oxygen, src.NormalOxygen)
sleep(5)
src.MaintainGas(src.Nitrogen, src.NormalNitrogen)
sleep(5)
src.MaintainGas(src.CarbonDioxide, src.NormalCarbonDioxide)
sleep(1)

proc
MaintainGas(var/current, var/normal)
if(current > normal)
current -= 0.50
usr << current
sleep(25)
return

if(current < normal)
current += 0.5
usr << current
sleep(25)
return

if(current == normal)
current += rand(-1,1)
usr << current
sleep(25)
return
In response to GreatFisher
All you're passing to MaintainGas() are two numbers. If you want to do it like that, you'll have to pass the names of the variables, like so:
datum
proc
// usage: src.clamp_var("health", 0, 100)
clamp_var(a, b, c)
if(a in vars)
vars[a] = min(max(a, b), c)
I dont see why, all he wants to do is make sure the number is where it is meant to be for that turf.(and wants to increase/decrease slowly, as if simulating random particle dispersion)
In response to GreatFisher
I don't know if this is in response to my post, but I should have made this clearer: Your code doesn't actually do anything. It changes the 'current' variable in the context of the proc only.

What my post was demonstrating is that if you want to modify a variable variable, one way would be to modify the "instance" of the variable, which exists as text in a datum's vars variable.
turf
var
Oxygen = 60
NormalOxygen = 20

Nitrogen = 6
NormalNitrogen = 78

CarbonDioxide = 90
NormalCarbonDioxide = 2

New()
..()

for()
sleep(1)
MaintainGas("Oxygen", "NormalOxygen")

sleep(5)
MaintainGas("Nitrogen", "NormalNitrogen")

sleep(5)
MaintainGas("CarbonDioxide", "NormalCarbonDioxide")

proc
MaintainGas(current, normal)
// 'current' and 'normal' need to be names of variables
if(!(current in vars) || !(normal in vars)) return

if(vars[current] == vars[normal])
vars[current] += rand(-1, 1)

else
if(vars[current] < vars[normal])
vars[current] -= 0.5
else vars[current] += 0.5

sleep(25)
Now I'm just confused, I literally have no idea what you are talking about but then I usually don't go around modifying the vars of turfs lol.
In response to GreatFisher
current and normal are passed into MaintainGas() by value, meaning that their values are copied into the argument variables, and are separate from their original sources (ie src.Oxygen and src.NormalOxygen). Changing the value of current will not affect src.Oxygen, or any of the other gas levels.

Numbers and text strings are passed by value, while datums (which includes lists, objects, icons, ect) are passed by reference (which means that they point to the same data as the variable you use to pass them).
Ahhh I see what you mean lol.
I have found this while looking around the forums.

Is it possible i can implement gasses into this?

turf
var
/*
holeinfloor = is there a hole in the floor that needs repair? 0 - no 1 - yes
breathableair = how much breathable air is there here?
vaccum = is this a space tile?
airpasshorizontal = is this a solid wall that air can pass through?
airpassfloor = is this an opening in the floor that air can pass through?
*/

holeinfloor = 0
breathableair = 9001
vaccum = 0
airpasshorizontal = 0
airpassfloor = 0
leakhorizontal
leakvertical

proc
Atmospherics()
while(1 == 1)
sleep(5)
for (var/turf/T in world)
if (istype(T, /turf/Space))
goto END
if (T.breathableair < 1)
T.breathableair = 0
goto END
if (T.z == 3)
goto END
var/air1 = T.breathableair
var/air2 = 0
var/x = T.x
var/y = T.y
var/z = T.z
var/turf/north
var/turf/south
var/turf/east
var/turf/west
var/turf/up
var/turf/down
var/turf/chosenspot
var/airtransfer
airtransfer = 0
/*for (var/turf/Tt in world)
if (Tt.x == x && Tt.y == (y + 1) && Tt.z == z)
north = Tt
if (Tt.x == x && Tt.y == (y - 1) && Tt.z == z)
south = Tt
if (Tt.x == (x + 1) && Tt.y == y && Tt.z == z)
east = Tt
if (Tt.x == (x - 1) && Tt.y == y && Tt.z == z)
west = Tt
if (Tt.x == x && Tt.y == y && Tt.z == (z + 1))
up = Tt
if (Tt.x == x && Tt.y == y && Tt.z == (z - 1))
down = Tt*/

if (y < world.maxy)
north = locate(x, y+1, z)
if (y > 1)
south = locate(x, y-1, z)
if (x < world.maxx)
east = locate(x+1, y, z)
if (x > 1)
west = locate(x-1, y, z)
if (z < world.maxz)
up = locate(x, y, z+1)
if (z > 1)
down = locate(x, y, z-1)
if (north == null) goto SOUTH
if (north.density == 0 || north.airpasshorizontal == 1 || north.leakhorizontal == 1)
air2 = north.breathableair
if (air2 < air1)
chosenspot = north
air1 = air2
SOUTH
if (south == null) goto EAST
if (south.density == 0 || south.airpasshorizontal == 1 || south.leakhorizontal == 1)
air2 = south.breathableair
if (air2 < air1)
chosenspot = south
air1 = air2
EAST
if (east == null) goto WEST
if (east.density == 0 || east.airpasshorizontal == 1 || east.leakhorizontal == 1)
air2 = east.breathableair
if (air2 < air1)
chosenspot = east
air1 = air2
WEST
if (west == null) goto UP
if (west.density == 0 || west.airpasshorizontal == 1 || west.leakhorizontal == 1)
air2 = west.breathableair
if (air2 < air1)
chosenspot = west
air1 = air2
UP
if (up == null) goto DOWN
if (up.airpassfloor == 1 || up.holeinfloor == 1 || up.leakvertical == 1)
air2 = up.breathableair
if (air2 < air1)
chosenspot = up
air1 = air2
DOWN
if (down == null) goto MOVEAIR
if (T.airpassfloor == 1 || T.holeinfloor == 1 || T.leakvertical == 1)
air2 = down.breathableair
if (air2 < air1)
chosenspot = down
air1 = air2
MOVEAIR
if (chosenspot == null) goto END
air1 = T.breathableair
air2 = chosenspot.breathableair
if (air2 < air1)
airtransfer = round(((air1 - air2) / 4), 100)
if (chosenspot.leakhorizontal || T.leakhorizontal || chosenspot.leakvertical || T.leakvertical)
airtransfer /= 4
T.breathableair -= airtransfer
if (T.breathableair < 0) T.breathableair = 0
chosenspot.breathableair += airtransfer
if (chosenspot.vaccum == 1) chosenspot.breathableair = 0
var/verticalmove = chosenspot.z - T.z
if (airtransfer > 500)
var/direct = get_dir(T, chosenspot)
for (var/mob/M in T)
if (M.movedbyair == 0)
if (chosenspot.density == 1) goto END
if (verticalmove == 1 && chosenspot.holeinfloor != 1) goto END
if (verticalmove == -1 && T.holeinfloor != 1) goto END
M.loc = chosenspot
M.momentumdirection = direct
M.attempteddirection = null
M.movedbyair = 1
spawn(4)
M.movedbyair = 0
for (var/obj/O in T)
if (O.movedbyair == 0 && O.anchored == 0)
if (chosenspot.density == 0) O.loc = chosenspot
O.momentumdirection = direct
O.movedbyair = 1
spawn(4)
O.movedbyair = 0
END
for(var/mob/M in world)
if (istype(M.loc, /turf/Space))
M.InSpace = 1
else
M.InSpace = 0
if (M.attempteddirection != null)
M.momentumdirection = M.attempteddirection
if (M.InSpace == 1 & M.momentumdirection != null)
if (M.momentumdirection == EAST && M.x == world.maxx) goto SKIP1
if (M.momentumdirection == WEST && M.x == 1) goto SKIP1
if (M.momentumdirection == NORTH && M.y == world.maxy) goto SKIP1
if (M.momentumdirection == SOUTH && M.y == 1) goto SKIP1
var/turf/nextstep = get_step(M, M.momentumdirection)
var/denseness = nextstep.density
if (denseness == 1) goto SKIP1
if (M.spacepull == 1) goto SKIP1
M.loc = get_step(M, M.momentumdirection)
M.spacepull = 1
spawn(8)
M.spacepull = 0
SKIP1
for(var/obj/O in world)
if (istype(O.loc, /turf/Space))
O.InSpace = 1
else
O.InSpace = 0
if (O.InSpace == 1 & O.momentumdirection != null && O.anchored == 0)
if (O.momentumdirection == EAST && O.x == world.maxx) goto SKIP2
if (O.momentumdirection == WEST && O.x == 1) goto SKIP2
if (O.momentumdirection == NORTH && O.y == world.maxy) goto SKIP2
if (O.momentumdirection == SOUTH && O.y == 1) goto SKIP2
var/turf/nextstep = get_step(O, O.momentumdirection)
var/denseness = nextstep.density
if (denseness == 1) goto SKIP2
if (O.spacepull == 1) goto SKIP2
O.loc = get_step(O, O.momentumdirection)
O.spacepull = 1
spawn(6)
O.spacepull = 0
SKIP2

world
New()
spawn(5)
Atmospherics()