Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --@name Colonial Airlock System|V2
- --@author Avorius
- --@shared
- --@class processor
- if SERVER then
- function CASV2(...)
- printColor(Color(216,38,57), "[CAS:V2]: ", Color(255,255,255), ...)
- end
- CASV2("Initialisation for the Colonial Airlock System|V2 will start in T-Minus 5 Seconds.")
- StartupPercent = 0
- StartupComplete = false
- Lockdown = false
- function startupSequence( )
- wire.createInputs({"OuterAirlock","InnerAirlock","Bulkhead","OuterCycleButton","InnerCycleButton","BulkheadButton"},{"wirelink","wirelink","wirelink","normal","normal","normal"})
- wire.createOutputs({"SealIndicator"},{"vector"})
- wire.ports.SealIndicator = Vector(255,95,0)
- timer.create("startupSequence" , 1, 5, function()
- CASV2("Initialising Colonial Airlock System|V2... "..StartupPercent.."%")
- StartupPercent = StartupPercent + 25
- if timer.repsLeft("startupSequence") == 1 then
- timer.simple(2,function()
- --Definition Variables for ease of use
- if IsValid(wire.ports.OuterAirlock) and
- IsValid(wire.ports.InnerAirlock) and
- IsValid(wire.ports.Bulkhead) and
- wire.ports.OuterCycleButton ~= nil and
- wire.ports.InnerCycleButton ~= nil and
- wire.ports.BulkheadButton ~= nil then
- OAIR = wire.ports.OuterAirlock
- IAIR = wire.ports.InnerAirlock
- BULK = wire.ports.Bulkhead
- OUTB = wire.ports.OuterCycleButton
- INNB = wire.ports.InnerCycleButton
- BULB = wire.ports.BulkheadButton
- if BULK["Opened"] == 1 then
- BULK["Toggle"] = 1
- end
- if IAIR["Opened_1"] == 1 then
- IAIR["Open_1"] = 0
- IAIR["Lock_1"] = 1
- end
- if OAIR["Opened_1"] == 0 then
- OAIR["Locked_1"] = 0
- OAIR["Open_1"] = 1
- end
- StartupComplete = true
- wire.ports.SealIndicator = Vector(255,0,0)
- CASV2("Colonial Airlock System|V2 initialisation complete!")
- timer.remove("startupSequence")
- else
- CASV2("Colonial Airlock System|V2 initialisation failed. Please wire up all the components and reload the chip.")
- end
- end)
- end
- end)
- end
- hook.add( "input", "inputHook", function( i, v )
- if StartupComplete then
- if i == "BulkheadButton" then
- if v == 1 then
- if BULK["Opened"] == 1 then
- Lockdown = true
- CASV2("Lockdown initiated!")
- BULK["Toggle"] = 1
- wire.ports.SealIndicator = Vector(255,0,0)
- IAIR["Lock_1"] = 1
- IAIR["Open_1"] = 0
- OAIR["Lock_1"] = 1
- else
- Lockdown = false
- CASV2("Lockdown lifted!")
- BULK["Toggle"] = 1
- wire.ports.SealIndicator = Vector(0,255,0)
- IAIR["Lock_1"] = 0
- IAIR["Open_1"] = 1
- OAIR["Lock_1"] = 0
- end
- end
- elseif i == "InnerCycleButton" then --Always use elseif for functions like these, it can only possibly be one no point in 3 separate checks
- if v == 1 then
- if Lockdown == false then
- if IAIR["Opened_1"] == 0 then
- CASV2("Cycling the airlock!")
- OAIR["Lock_1"] = 1
- timer.simple(3, function()
- IAIR["Lock_1"] = 0
- IAIR["Open_1"] = 1
- end)
- else
- CASV2("Cycling the airlock!")
- IAIR["Lock_1"] = 1
- timer.simple(3, function()
- OAIR["Lock_1"] = 0
- OAIR["Open_1"] = 1
- end)
- end
- else
- CASV2("Cannot comply! Lockdown has been initiated!")
- end
- end
- elseif i == "OuterCycleButton" then
- if Lockdown == false then
- if v == 1 then
- if IAIR["Opened_1"] == 0 then
- CASV2("Cycling the airlock!")
- OAIR["Lock_1"] = 1
- timer.simple(3, function()
- IAIR["Lock_1"] = 0
- IAIR["Open_1"] = 1
- end)
- else
- CASV2("Cycling the airlock!")
- IAIR["Lock_1"] = 1
- timer.simple(3, function()
- OAIR["Lock_1"] = 0
- OAIR["Open_1"] = 1
- end)
- end
- end
- else
- CASV2("Cannot comply! Lockdown has been initated!")
- end
- end
- end
- end)
- timer.simple(5,function()
- startupSequence()
- end)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement