This commit is contained in:
Paul Liverman III 2019-03-07 13:29:13 -08:00
commit 8d9991fb2e
43 changed files with 805 additions and 0 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
*.lua

23
images Normal file
View File

@ -0,0 +1,23 @@
abstract-029 -> fuel cell!
USED abstract-045 -> filterpump?
abstract-050 -> vent (for filters/pumps)!
abstract-072 -> thruster!
airtight-hatch -> closed airlock!
airtight-hatch-1 -> open airlock!
ammo-box -> ammo?
USED chemical-tank -> tanks!
circuitry -> computer
convergence-target -> ?
cryo-chamber -> clone bay!
energy-tank -> ?
expanded-rays -> antimatter reactor!
hospital-cross -> medical cabinet?
metal-scales -> ?
paper-tray -> ?
USED person -> you!
USED plain-square -> flooring / internal space!
power-generator -> fabricator!
targeted -> ?
tinker -> repair needed icon ?
triangle-target -> ?
wooden-crate -> cargo space? (or actual cargo?)

60
life-support Normal file
View File

@ -0,0 +1,60 @@
21% normal
5% consumption
volume of breath? 6 litres
16 breaths per minute
our units are approximately 1/5 a litre
6 * 1/5 * 16 / 60 * 0.05 = oxygen per second rate = 0.016
co2
> 0.0008 is unhealthy
> 0.005 is very unhealthy
> 0.05 is dangerous to animal life (becomes uncomfortable as well)
> 0.084 for 60 minutes = death
> 0.1 is immediately dangerous
o2 below 19.5% is considered dangerous
0.47 pressure at 21% is lowest pressure
- 5 to 8 psi for 100% is tolerable (1 psi = 0.068046 atm)
(should be roughly 0.12 atm (minimum at 100%))
2.5 atm at 21% should be a safe maximum, short periods in excess of 70 atm are tolerable
Min Pressure: 0.12 atm with pure oxygen
Max Pressure with pure oxygen: 0.5 atm
Min Pressure w 19.5-21%: 0.47 atm
Max Pressure with 19.5-21%: 2.5 atm
- draw a box, current point has to be in the box? NO
if oxygen < 0.195 -> dying
if pressure < 0.12 -> dying
if pressure < 0.47
if oxygen < -2.3(pressure) + 1.276 -> dying
if pressure > 0.5
if oxygen > -.054(pressure) + 0.33 -> oxy toxicity
if pressure > 2.5 -> oxy toxicity
min pressures: 0.12 and 0.47
max pressures: 0.5 and 2.5
min percents: 1 and 1
max percents
feces
3-8oz per day -> * 0.0295735 / 5 = volume units
= 0.03253085 / 24 / 60 / 60 = 3.7651446759259e-07 per second
75% water, 25% solid (below list)
0.3 -> bacteria
0.3 -> cellulose (can be burned -> co2 h2o)
0.1-0.2 -> fats
0.1-0.2 -> phosphates (iron/calcium)
0.02-0.03 -> proteins
(one urination ~ 0.35 / 5 volume)
per day => 0.8 to 2 litres
per second = 3.2407407407407e-06
urine
~0.04 urea (ammonia/co2)
~0.01 salt, potassium
0.95 water
0.4 litres of water expelled in breath per day
per second: 0.4 / 5 / 24 / 60 / 60 = 9.2592592592593e-07

34
notes Normal file
View File

@ -0,0 +1,34 @@
Survival in ship, console / UI is only interface, must repair broken systems.
Walk around to repair various panels.
Randomly generated ship layout?
What systems are needed? Toilet, bed, medical cabinet, thrusters, warp drive,
reactor, battery, fuel / fluid storage, airlock, computer, sensors, weapons?,
cargo area, grappling hook / docking system, piping and wiring of course,
filters, pumps, atmospheric sensors, lights, toolbox, locker
How about a starbase instead? Starting with just a small number of components,
and events come to you.
- Could still implement travel, just through warp drive only. You have station-
keeping thrusters to maintain, but no main engines.
- If you lose thrusters, your orbit starts slowly decaying (you can still just
warp to a higher orbit of course)
- Start to fall into atmosphere? Can scoop from upper atmospheres, but starts to
decay faster.
- Send out mining drones.
- 3D Printing tech? For manufacture? fluid plastic
Each tile needs to reference a Fluid (atmosphere). Volumes of atmosphere Fluids
are equal to 10 per tile. Volumes of single tanks are 8 per.
Doubles: 4 Triples: 3
Start:
- basic life support: bed, toilet, kitchen, atmospheric sensor, filter, pump,
tankage (o2, co2, n2)
(maybe I should use the scuba tanks icon for multiple tanks in one spot?)
- one thruster, uses n2
- battery, solar panels? (start in orbit close enough to a star?)
- warp drive, barely capable of warping your station
- docking arm / airlock (airlock at end of pylon)
- computer, basic sensors?, filters/pumps?, lights?
- locker w toolbox (locker is our cargo space to start)

24
src/Breach.moon Normal file
View File

@ -0,0 +1,24 @@
class Breach
new: (@high, @low, @volume=1) =>
update: (dt) =>
a, b = @high\pressure!, @low\pressure!
if b > a
tmp = @high
@high = @low
@low = tmp
tmp = a
a = b
b = tmp
elseif a > b
@active = true
else
@active = false
-- print "High: #{a}", "Low: #{b}", "Active? #{@active}"
if @active
sum = (a - b) * @volume * dt
for type in pairs @high.contents
tmp = sum * @high\percent type
-- print "Moving #{tmp} #{type}.."
@high\remove type, tmp
@low\add type, tmp

22
src/Filter.moon Normal file
View File

@ -0,0 +1,22 @@
class Filter
new: (@high, @low, @allows={}, @volume=1) =>
update: (dt) =>
a, b = @high\pressure!, @low\pressure!
if b > a
tmp = @high
@high = @low
@low = tmp
tmp = a
a = b
b = tmp
elseif a > b
@active = true
else
@active = false
if @active
sum = (a - b) * @volume * dt
for type in pairs @allows
tmp = sum * @high\percent type
@high\remove type, tmp
@low\add type, tmp

15
src/FilterPump.moon Normal file
View File

@ -0,0 +1,15 @@
import abs, min from math
class FilterPump
new: (@source, @destination, @allows={}, @volume=1, @rate=0) =>
reverse: =>
tmp = @source
@source = @destination
@destination = tmp
update: (dt) =>
if @rate > 0
sum = abs(@source\pressure! - @destination\pressure!) * @rate * @volume * dt
for type, amount in pairs @allows
tmp = sum * @source\percent type
@source\remove type, tmp
@destination\add type, tmp

19
src/Fluid.moon Normal file
View File

@ -0,0 +1,19 @@
class Fluid
new: (@volume=1) =>
@contents = {}
@sum = 0
add: (type, amount) =>
@contents[type] = 0 unless @contents[type]
@contents[type] += amount
@sum += amount
remove: (type, amount) =>
@contents[type] = 0 unless @contents[type]
@contents[type] -= amount
@sum -= amount
pressure: =>
return @sum / @volume
percent: (type) =>
return 0 unless @contents[type]
return @contents[type] / @sum
amount: =>
return @contents[type] or 0

101
src/Player.moon Normal file
View File

@ -0,0 +1,101 @@
import max, min from math
o2_consumption = 0.016
h2o_production = 9.2592592592593e-07
co2_production = 0.016
feces_production = 3.7651446759259e-07 -- want at 0.032, involuntary at 0.06
urine_production = 3.2407407407407e-06 -- want to urinate at 0.09, involuntary at 0.11
class Player
new: (@structure, @x=0, @y=0) =>
@state = {
"oxygen starvation": 0
"oxygen toxicity": 0
"nitrogen narcosis": 0
"helium narcosis": 0
"carbon dioxide poisoning": 0
}
@feces = 0
@urine = 0
@actionTimer = 0
if row = @structure[@x]
if tile = row[@y]
@atmosphere = tile.atmosphere
update: (dt, input) =>
if not @atmosphere
@state["oxygen starvation"] += dt
else
pressure = @atmosphere\pressure!
o2 = @atmosphere\percent "O2"
if o2 < 0.195
@state["oxygen starvation"] += dt
else
@state["oxygen starvation"] = max 0, @state["oxygen starvation"] - dt / 2
@state["oxygen starvation"] += dt if pressure < 0.12
@state["oxygen starvation"] += dt if pressure < 0.47 and o2 < -2.3 * pressure + 1.276
if pressure > 2.5 or (pressure > 0.5 and o2 > -0.054 * pressure + 0.33)
@state["oxygen toxicity"] += dt
if o2 > 0.195
@state["oxygen starvation"] = max 0, @state["oxygen starvation"] - dt * 3
else
@state["oxygen toxicity"] = max 0, @state["oxygen toxicity"] - dt * 2
if pressure > 50
n2 = @atmosphere\percent "N2"
he = @atmosphere\percent "He"
@state["nitrogen narcosis"] += dt if n2 > 0.5
@state["helium narcosis"] += dt if pressure > 500 and he > 0.5 and n2 < 0.25
else
@state["nitrogen narcosis"] = max 0, @state["nitrogen narcosis"] - dt * 4
@state["helium narcosis"] = max 0, @state["helium narcosis"] - dt * 8
co2 = @atmosphere\percent "CO2"
if co2 > 0.005
@state["carbon dioxide poisoning"] += dt * (220 * co2 - 0.1)
elseif co2 < 0.005
@state["carbon dioxide poisoning"] = max 0, @state["carbon dioxide poisoning"] - dt
-- using min garuntees we will not cause a negative oxygen
-- it is assumed co2/h20 output will be stable until death when there is
-- not enough oxygen
@atmosphere\remove "O2", min o2, o2_consumption * dt
@atmosphere\add "CO2", co2_production * dt
@atmosphere\add "H2O", h2o_production * dt
if @state["oxygen starvation"] >= 2.5 * 60 or
@state["oxygen toxicity"] >= 60 * 60 or
@state["carbon dioxide poisoning"] >= 60 * 60
print "Dead."
@actionTimer -= dt
if @actionTimer <= 0
x, y = input\get "move"
if x != 0 or y != 0
if x < 0
x = -1
elseif x > 0
x = 1
if y < 0
y = -1
elseif y > 0
y = 1
if @getTile! -- if inside
if tile = @getTile x, y
if tile.obj
nil -- TODO access the object (or go through airlock)
else
@actionTimer = 1/6
@x += x
@y += y
@atmosphere = tile.atmosphere -- assumes atmosphere might be different, but that only happens when passing through an airlock
else -- outside
if tile = @getTile x, y
if tile.obj
nil -- TODO access (or go through airlock)
else
nil -- TODO move
getTile: (x=0, y=0) =>
if row = @structure[@x + x]
return row[@y + y]

15
src/Pump.moon Normal file
View File

@ -0,0 +1,15 @@
import abs, min from math
class Pump
new: (@source, @destination, @volume=1, @rate=0) =>
reverse: =>
tmp = @source
@source = @destination
@destination = tmp
update: (dt) =>
if @rate > 0
sum = abs(@source\pressure! - @destination\pressure!) * @rate * @volume * dt
for type, amount in pairs @source.contents
tmp = sum * @source\percent type
@source\remove type, tmp
@destination\add type, tmp

66
src/Structure.moon Normal file
View File

@ -0,0 +1,66 @@
import graphics from love
width, height = graphics.getDimensions!
x_center, y_center = width / 2, height / 2
x_offset, y_offset = math.floor(width / 4), math.floor(height / 4)
images = require "images"
colors = require "colors"
Fluid = require "Fluid"
fluids = require "fluids"
class Structure
new: (tiles_or_size=2) =>
@systems = {}
if "table" == type tiles_or_size
for x, row in pairs tiles_or_size
@[x] = {}
for y, tile in pairs row
@[x][y] = tile
if tile.systems
for system in *tile.systems
table.insert @systems, tile.systems
else
volume = 10 * (2 * tiles_or_size + 1) ^ 2
air = Fluid(volume)
for type, percent in pairs fluids.air
air\add type, volume * percent
for x = -tiles_or_size, tiles_or_size
@[x] = {}
for y = -tiles_or_size, tiles_or_size
@[x][y] = { img: "plain-square.png", color: colors.floor, atmosphere: air }
-- temporary
system = require("FilterPump")(@[0][0].atmosphere, Fluid(math.huge), { CO2: true }, 8, 1)
@[0][1] = {
img: "plain-square.png"
obj: "abstract-045.png", color: colors.dark
systems: { system }
atmosphere: @[0][0].atmosphere
}
@systems[1] = system
tank = Fluid(8)
tank\add "O2", 100
tanksys = require("Pump")(tank, @[0][0].atmosphere, 1, 0.0015)
@[1][0] = {
img: "plain-square.png"
obj: "chemical-tank.png", color: colors.blue
systems: { tanksys }
atmosphere: @[0][0].atmosphere
}
@systems[2] = tanksys
update: (dt) =>
for system in *@systems
system\update dt
draw: (location) =>
for x = location.x - x_offset, location.y + x_offset
if row = @[x]
for y = location.y - y_offset, location.y + y_offset
if tile = row[y]
graphics.setColor colors.floor
graphics.draw images[tile.img], (x - location.x) * 32 + x_center, (y - location.y) * 32 + y_center, 0, 1/16, 1/16, 256, 256
if tile.obj
graphics.setColor tile.color or 1, 1, 1, 1
graphics.draw images[tile.obj], (x - location.x) * 32 + x_center, (y - location.y) * 32 + y_center, 0, 1/16 * 0.9, 1/16 * 0.9, 256, 256

24
src/Valve.moon Normal file
View File

@ -0,0 +1,24 @@
import min from math
class Valve
new: (@high, @low, @volume=1, @rate=0) =>
update: (dt) =>
a, b = @high\pressure!, @low\pressure!
if b > a
tmp = @high
@high = @low
@low = tmp
tmp = a
a = b
b = tmp
elseif a > b
@active = true
else
@active = false
if @active
sum = (a - b) * min(@rate, @volume) * dt
for type in pairs @high.contents
tmp = sum * @high\percent type
@high\remove type, tmp
@low\add type, tmp

7
src/colors.moon Normal file
View File

@ -0,0 +1,7 @@
{
default: { 1, 1, 1, 1 }
floor: { 2/3, 2/3, 2/3, 1 }
dark: { 1/3, 1/3, 1/3, 1 }
blue: { 0, 0, 1/3, 1 }
player: { 0, 0, 1, 1 }
}

3
src/ecs.moon Normal file
View File

@ -0,0 +1,3 @@
Systems: Valve, Pump, Filter, Player
Components: volume, area, controls, sum, floor, rate, filter
Entities: tile, player

18
src/fluids.moon Normal file
View File

@ -0,0 +1,18 @@
{
earth: { A: 0.0069, H2O: 0.0039, CO2: 0.0004, Ne: 0.000015, N2: 0.779885, O2: 0.2089 }
air: { N2: 0.78, O2: 0.22 }
feces: {
H2O: 0.75, organics: 0.25 * 0.335, C6H10O5: 0.25 * 0.335
phosphates: 0.25 * 0.152, fats: 0.25 * 0.152, proteins: 0.25 * 0.026
}
urine: { H2O: 0.95, urea: 0.04, salts: 0.01 } -- sodium/potassium salts
organics: {
C: 0.504, O2: 0.202, N2: 0.141, H2: 0.081, P: 0.03, S: 0.01, K: 0.01, Mg: 0.005
Ca: 0.005, Fe: 0.002, Mn: 0.001, Co: 0.001, Zn: 0.001, Cu: 0.001, Mo: 0.001
}
-- phosphates: { iron: 0.33, calcium: 0.33, phosphor: 0.34 }
-- FePO4 & Ca3(PO4)2
}
-- C6 H10 O5 + 6x 02 -> 6x C 02 + 5x H2 0
-- 6 oxygen + 1 cellulose -> 6 carbon dioxide + 5 water

4
src/images.moon Normal file
View File

@ -0,0 +1,4 @@
images = {}
for img in *love.filesystem.getDirectoryItems "img"
images[img] = love.graphics.newImage "img/#{img}"
images

BIN
src/img/abstract-029.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

BIN
src/img/abstract-045.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

BIN
src/img/abstract-050.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.5 KiB

BIN
src/img/abstract-072.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 25 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.6 KiB

BIN
src/img/airtight-hatch.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

BIN
src/img/ammo-box.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

BIN
src/img/chemical-tank.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

BIN
src/img/circuitry.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

BIN
src/img/cryo-chamber.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

BIN
src/img/energy-tank.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

BIN
src/img/expanded-rays.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 31 KiB

BIN
src/img/hospital-cross.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

BIN
src/img/metal-scales.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

BIN
src/img/paper-tray.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

BIN
src/img/person.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

BIN
src/img/plain-square.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.3 KiB

BIN
src/img/power-generator.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

BIN
src/img/targeted.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 25 KiB

BIN
src/img/tinker.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

BIN
src/img/triangle-target.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

BIN
src/img/wooden-crate.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

87
src/main.moon Normal file
View File

@ -0,0 +1,87 @@
lurker = require "lurker"
lurker.quiet = true
debug = true
baton = require "baton"
input = baton.new {
controls:
left: { 'key:left', 'key:a', 'axis:leftx-', 'button:dpleft' }
right: { 'key:right', 'key:d', 'axis:leftx+', 'button:dpright' }
up: { 'key:up', 'key:w', 'axis:lefty-', 'button:dpup' }
down: { 'key:down', 'key:s', 'axis:lefty+', 'button:dpdown' }
-- action: { 'key:x', 'button:a' }
exit: { 'key:escape' }
pairs:
move: { 'left', 'right', 'up', 'down' }
joystick: love.joystick.getJoysticks![1]
}
images = require "images"
colors = require "colors"
-- floor = { img: "plain-square.png", color: colors.floor }
Structure = require "Structure"
structure = Structure(3)
Player = require "Player"
player = Player(structure)
love.update = (dt) ->
-- dt *= 100
require("lovebird").update!
lurker.update!
input\update!
love.event.quit! if input\pressed "exit"
player\update(dt, input)
structure\update dt
if debug
if row = structure[player.x]
if tile = row[player.y]
atmosphere = tile.atmosphere
if love.keyboard.isDown("c")
atmosphere\add "CO2", 1
if love.keyboard.isDown("n")
atmosphere\add "N2", 10
if love.keyboard.isDown("o")
atmosphere\add "O2", 1
if love.keyboard.isDown("h")
atmosphere\add "He", 10
-- structure[player.x] = {} unless structure[player.x]
-- structure[player.x][player.y] = { img: "plain-square.png", color: colors.floor } unless structure[player.x][player.y]
width, height = love.graphics.getDimensions!
love.draw = ->
if debug
-- love.graphics.setColor 1, 1, 1, 1/4
-- love.graphics.line width / 2, 0, width / 2 , height
-- love.graphics.line 0, height / 2, width, height / 2
love.graphics.setColor 1, 1/3, 1/3, 1
love.graphics.line -player.x * 32 + width / 2, 0, -player.x * 32 + width / 2, height
love.graphics.line 0, -player.y * 32 + height / 2, width, -player.y * 32 + height / 2
structure\draw player
love.graphics.setColor colors.player
love.graphics.draw images["person.png"], width / 2, height / 2, 0, 1/16 * 0.9, 1/16 * 0.9, 256, 256
if debug
if row = structure[player.x]
if tile = row[player.y]
if atmosphere = tile.atmosphere
love.graphics.setColor 1, 1, 1, 1
love.graphics.print "Pressure: #{math.floor(10 * atmosphere\pressure!) / 10} atm (#{math.floor(10 * atmosphere.sum) / 10})", 0, 0
i = 1
for type, amount in pairs atmosphere.contents
love.graphics.print "#{type}: #{math.floor(1000 * atmosphere\percent type) / 10}% (#{math.floor(100 * amount) / 100})", 0, i * 15
i += 1
i = 0
love.graphics.setColor 1, 1, 1, 1
for state, value in pairs player.state
if value > 0
love.graphics.print "Warning: #{state} (#{math.floor value})", width / 2, i * 15
i += 1

246
src/station.moon Normal file
View File

@ -0,0 +1,246 @@
station = {
player: { x: 0, y: 2 }
{
x: -2, y: -2
"airlock"
-- connections: { "atmosphere", "vacuum" }
}
{
x: -1, y: -2
"tank"
connections: { "fabricator" }
}
{
x: 0, y: -2
"fabricator"
}
{
x: 1, y: -2
"tank"
}
{
x: 2, y: -2
"thruster"
}
{
x: -1, y: 0
"warp drive"
}
{
x: 0, y: 0
"battery"
}
{
x: 1, y: 0
"computer"
}
{
x: -1, y: 1
"tank", "H2", 12.5
}
{
x: 0, y: 1
"fuel cell", "H2O", 0.1
}
{
x: 1, y: 1
"tank", "O2", 12.5
}
{
x: 2, y: 0
"locker"
}
{
x: 2, y: 1
"bed"
}
{
x: -2, y: 3
"thruster"
}
{
x: 0, y: 3
"toilet"
}
{
x: 1, y: 3
"tank", "organic waste", 0.01
}
{
x: 2, y: 3
"water reclamation unit"
}
{
x: -3, y: 0
"tank", "H20", 0.1
}
{
x: -3, y: 1
"tank", "H20", 0.1
}
{
x: 3, y: 0
"tank", "N2", 12
}
{
x: 3, y: 1
"tank", "N2", 12
}
{
x: 0, y: -5
"solar panel"
}
{
x: 0, y: -4
"solar panel"
}
{
x: 0, y: -3
"solar panel"
}
{
x: 0, y: 4
"solar panel"
}
{
x: 0, y: 5
"solar panel"
}
{
x: 0, y: 6
"solar panel"
}
-- systems: {
-- { "airlock", "atmosphere" }
-- { "tank:H2", "fuel cell" }
-- { "tank:O2", "fuel cell" }
-- { "thruster", "tank:N2" }
-- }
}
Fluid = require "Fluid"
fluids = require "fluids"
vaccum = Fluid(math.huge)
station = {
atmosphere: Fluid() -- volume is corrected by Structure()
systems: {
-- "exterior hatch": Valve()
"airlock": Fluid(10)\fill fluids.air -- TODO write it, needs to return self
"oxygen tank": Fluid(8)\fill "O2", 12.5
"hydrogen tank": Fluid(8)\fill "H2", 12.5
"water tank": Fluid(12)\fill "H2O", 1/2
"water tank 2": Fluid(12)\fill "H2O", 1/2
"nitrogen tank": Fluid(12)\fill "N2", 10
"nitrogen tank 2": Fluid(12)\fill "N2", 10
"waste tank": Fluid(8)\fill "organic waste", 0.01
"fuel cell": Fluid(5)\fill "H2O", 0.1
-- "thruster": Thruster("nitrogen tank")
Valve("nitrogen tank", "nitrogen tank 2")
}
}
-- 12.5 atm pressure in oxy tanks
fluids = require "fluids"
station = {
atmosphere: Fluid() -- volume to be reassigned later
}
vaccum_source = Fluid(math.huge)
n2_source = Fluid(12)\fill "N2", 12.5 -- TODO make fill function!
station[3] = {
[0]: {
img: "chemical-tank.png"
systems: { n2_source }
}
[1]: ->
tank = Fluid(12)\fill "N2", 12.5
return {
img: "chemical-tank.png"
systems: { tank, Valve(tank, n2_source, 1, 1) }
}
}
station[-2] = {
[-2]: ->
airlock = Fluid(10)\fill fluids.air -- TODO make fill function, make it return self
exterior = Valve(airlock, vaccum_source, 7.5, 0)\set "name", "exterior hatch" -- TODO make set function
interior = Valve(airlock, station.atmosphere, 8, 0)\set "name", "interior hatch"
return {
img: "airtight-hatch.png"
systems: { airlock, exterior, interior }
}
[3]: ->
thruster = Thruster()
return {
img: "abstract-072.png"
systems: { thruster, Valve(n2_source, thruster, 1, 0)\set "name", "thruster" }
}
}
Volume(8)\add "O2", 100
station = {}
for x = -2, 2
station[x] = {}
for y = -2, 3
station[x][y] = {
hull: true -- show floor
}
airlock = station[-2][-2]
fab_tank = station[-1][-2]
fab = station[0][-2]
fab_tank2 = station[1][-2]
thruster = station[2][-2]
-- idea, create objects with x/y values, insert them later
airlock = {
hatch: true
}
import insert from table
import Volume from require "fluids"
Tank = (t) ->
if fucked
nil
o2 = {internal}
internal = 8
external = 12
full = 100
half = 50
o2 = Tank internal, full
-- systems = {
-- O2: Volume(8)\add "O2", 100
-- H2: Volume(8)\add "H2", 100
-- N2: Volume(12)\add "N2", 150
-- -- N2_2: Volume(12)\add "N2", 150
-- H2O: Volume(12)\add "H2O", 50
-- -- H2O_2: Volume(12)\add "H2O", 50
-- }
systems = {}
insert Volume(8)\add "O2", 100

12
systems Normal file
View File

@ -0,0 +1,12 @@
Systems
- Movement, done.
- Fluid physics, done.
- Fluid handling.
- Filters to allow transferring only one type of fluid at a time, done.
- Pumps to allow transferring from low pressure to high pressure, done.
- Needs (sleep, food, air, water, waste disposal).
- Sleep timer refreshed by skipping some time. Events can interrupt sleep.
Will pass out and not be awoken for a while if you let it get too low.
- Food & Water. (Consumable items.)
- Air. Regularly removing oxygen and adding co2 and h20.
- Waste. Liquid (urea(co2&ammonia)&h2o) and Solid ('organic waste'?)

24
tmp/Fluid.moon Normal file
View File

@ -0,0 +1,24 @@
-- what kind of usage do I want?
tank = Container(volume):add("O2", 400)
o2_control = Valve(tank, atmosphere, 0) -- rate/area/whatever
-- remember, Containers don't need to be updated, everything else does
fluid = require "fluid"
ls_tank = fluid.Container(volume):add("O2")
fluid.Mix(ls_tank, fluid.vaccum, 0.001)
a = Container(volume):add('co2', 300):add('o2', 100)
Mix(a, Container.vaccum, 0.01) -- rate/volume/area specified (your choice of meaning lol)
Pump(a, b, 1) --rate/volume/area, your choice
Filter(a, b, 0.1) -- rate/volume/area, whatever
Mix(a, b, rate, filter)
-- with optional filter / rate (if rate is zero, disabled, if rate is anything
-- else, affects pressure dynamic (like, does it work against pressure?))