Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Skeleton code for reactor api
- local Reactor = {}
- Reactor.Rod = function(rod)
- local Rod = {
- index = 1,
- level = 0,
- name = "",
- valid = false,
- }
- Rod.__index = Rod
- rod = rod or {}
- setmetatable(rod, Rod)
- return {
- index = function()
- return rod.index
- end,
- level = function()
- return rod.level
- end,
- name = function()
- return rod.name
- end,
- setLevel = function(new_level)
- rod.level = new_level
- end,
- setName = function(new_name)
- rod.name = new_name
- end,
- valid = function()
- return rod.valid
- end,
- }
- end
- Reactor.Battery = function(battery)
- local Battery = {
- capacity = 0,
- stored = 0,
- }
- Battery.__index = Battery
- battery = battery or {}
- setmetatable(battery, Battery)
- return {
- capacity = function()
- return battery.capacity
- end,
- producedLastTick = function()
- return 0
- end,
- stored = function()
- return battery.stored
- end,
- }
- end
- Reactor.CoolantTank = function(coolant_tank)
- local CoolantTank = {
- capacity = 0,
- cold_fluid_amount = 0,
- hot_fluid_amount = 0,
- }
- CoolantTank.__index = CoolantTank
- coolant_tank = coolant_tank or {}
- setmetatable(coolant_tank, CoolantTank)
- return {
- capacity = function()
- return coolant_tank.capacity
- end,
- coldFluidAmount = function()
- return coolant_tank.cold_fluid_amount
- end,
- dump = function()
- return
- end,
- hotFluidAmount = function()
- return coolant_tank.hot_fluid_amount
- end,
- maxTransitionedLastTick = function()
- return 0
- end,
- transitionedLastTick = function()
- return 0
- end,
- }
- end
- Reactor.FuelTank = function(fuel_tank)
- local FuelTank = {
- capacity = 0,
- fuel_amount = 0,
- fuel_reactivity = 0,
- waste_amount = 0,
- }
- FuelTank.__index = FuelTank
- fuel_tank = fuel_tank or {}
- setmetatable(fuel_tank, FuelTank)
- return {
- burnedLastTick = function()
- return 0
- end,
- capacity = function()
- return fuel_tank.capacity
- end,
- ejectWaste = function()
- return
- end,
- fuel = function()
- return fuel_tank.fuel_amount
- end,
- fuelReactivity = function()
- return fuel_tank.fuel_reactivity
- end,
- totalReactant = function()
- return 0
- end,
- waste = function()
- return fuel_tank.waste_amount
- end,
- }
- end
- Reactor.Reactor = function(reactor)
- local Reactor = {
- active = false,
- ambient_temp = 0,
- battery = Reactor.Battery(),
- casing_temp = 0,
- connected = false,
- control_rods = {},
- coolant_tank = Reactor.CoolantTank(),
- fuel_tank = Reactor.FuelTank(),
- fuel_temp = 0,
- stack_temp = 0,
- }
- Reactor.__index = Reactor
- reactor = reactor or {}
- setmetatable(reactor, Reactor)
- return {
- active = function()
- return reactor.active
- end,
- ambientTemperature = function()
- return reactor.ambient_temp
- end,
- battery = function()
- return reactor.battery
- end,
- controlRodCount = function()
- return #reactor.control_rods
- end,
- coolantTank = function()
- return reactor.coolant_tank
- end,
- fuelTank = function()
- return reactor.fuel_tank
- end,
- fuelTemperature = function()
- return reactor.fuel_temp
- end,
- getControlRod = function(index)
- return reactor.control_rods[index]
- end,
- setActive = function(active)
- reactor.active = active
- end,
- setAllControlRodLevels = function(level)
- for _, rod in ipairs(reactor.control_rods) do
- rod.setLevel(level)
- end
- end,
- stackTemperature = function()
- return reactor.stack_temp
- end,
- }
- end
- return Reactor
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement