mirror of
https://github.com/AR2000AR/openComputers_codes.git
synced 2025-09-08 14:41:14 +02:00
[stargate2_bios] BIOS version of iris ctrl
This commit is contained in:
@@ -373,14 +373,25 @@
|
||||
["stargate2"] = {
|
||||
["manifestVersion"] = "1.0",
|
||||
["package"] = "stargate2",
|
||||
["version"] = "1.0.2",
|
||||
["version"] = "1.0.3",
|
||||
["name"] = "Stargate Ctl",
|
||||
["repo"] = "tree/master/stargate_crl",
|
||||
["repo"] = "tree/master/stargate_crl2",
|
||||
["description"] = "GUI to controll stargates from SGCraft",
|
||||
["authors"] = "AR2000AR",
|
||||
["dependencies"] = {
|
||||
["yaowbgl"] = "oppm"
|
||||
},
|
||||
["archiveName"] = "stargate2.tar"
|
||||
},
|
||||
["stargate2_bios"] = {
|
||||
["manifestVersion"] = "1.0",
|
||||
["package"] = "stargate2_bios",
|
||||
["version"] = "1.0.0",
|
||||
["name"] = "Stargate Ctl BIOS",
|
||||
["repo"] = "tree/master/stargate_crl2_bios",
|
||||
["description"] = "A small BIOS compatible program to make a gate smart",
|
||||
["note"] = "/usr/share/stargate/stargate.bios",
|
||||
["authors"] = "AR2000AR",
|
||||
["archiveName"] = "stargate2_bios.tar"
|
||||
}
|
||||
}
|
BIN
packages/stargate2_bios.tar
Normal file
BIN
packages/stargate2_bios.tar
Normal file
Binary file not shown.
15
programs.cfg
15
programs.cfg
@@ -385,10 +385,21 @@
|
||||
name = "Stargate Ctl",
|
||||
description = "GUI to controll stargates from SGCraft",
|
||||
authors = "AR2000AR",
|
||||
repo = "tree/master/stargate_crl",
|
||||
version = "1.0.2",
|
||||
repo = "tree/master/stargate_crl2",
|
||||
version = "1.0.3",
|
||||
dependencies = {
|
||||
["yaowbgl"] = "/"
|
||||
}
|
||||
},
|
||||
["stargate2_bios"] = {
|
||||
files = {
|
||||
[":master/stargate_ctl2_bios/share/"] = "/share"
|
||||
},
|
||||
name = "Stargate Ctl BIOS",
|
||||
description = "A small BIOS compatible program to make a gate smart",
|
||||
note = "/usr/share/stargate/stargate.bios",
|
||||
authors = "AR2000AR",
|
||||
repo = "tree/master/stargate_crl2_bios",
|
||||
version = "1.0.0",
|
||||
}
|
||||
}
|
||||
|
88
stargate_ctl2_bios/share/stargate/stargate.bios
Normal file
88
stargate_ctl2_bios/share/stargate/stargate.bios
Normal file
@@ -0,0 +1,88 @@
|
||||
local stargate = component.proxy(component.list('stargate')())
|
||||
if (not stargate) then error("No stargate") end
|
||||
---@cast stargate ComponentStargate
|
||||
|
||||
local smartRemote = false
|
||||
local lastIrisCmd = ''
|
||||
local doOnce = false
|
||||
local cTime = math.huge
|
||||
|
||||
local RemoteGate = {}
|
||||
|
||||
function RemoteGate.closeIris()
|
||||
stargate.sendMessage("SGCONTROLLER", "IRIS", "", false)
|
||||
lastIrisCmd = 'close'
|
||||
end
|
||||
|
||||
function RemoteGate.openIris()
|
||||
stargate.sendMessage("SGCONTROLLER", "IRIS", "", true)
|
||||
lastIrisCmd = 'open'
|
||||
end
|
||||
|
||||
function RemoteGate.ping()
|
||||
stargate.sendMessage("SGCONTROLLER", "PING", "" or "", "ping")
|
||||
end
|
||||
|
||||
local function onMessageReceived(protocol, command, password, arg, reason)
|
||||
if (not protocol == "SGCONTROLLER") then return end
|
||||
if (command == "IRIS") then
|
||||
if (arg == nil) then
|
||||
stargate.sendMessage("SGCONTROLLER", "IRIS", true, stargate.irisState())
|
||||
else
|
||||
if (arg == true) then
|
||||
stargate.sendMessage("SGCONTROLLER", "IRIS_A", true, stargate.openIris())
|
||||
else
|
||||
stargate.sendMessage("SGCONTROLLER", "IRIS_A", true, stargate.closeIris())
|
||||
end
|
||||
end
|
||||
elseif (command == 'IRIS_A') then
|
||||
if (arg == true and password == true) then
|
||||
if (lastIrisCmd == 'open') then
|
||||
stargate.openIris()
|
||||
lastIrisCmd = ''
|
||||
elseif (lastIrisCmd == 'close') then
|
||||
stargate.closeIris()
|
||||
lastIrisCmd = ''
|
||||
end
|
||||
end
|
||||
elseif (command == "PING") then
|
||||
if (arg == "ping") then
|
||||
stargate.sendMessage("SGCONTROLLER", "PING", true, "pong")
|
||||
elseif (arg == 'pong') then
|
||||
smartRemote = true
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
while true do
|
||||
if (stargate.stargateState() == 'Connected' and doOnce and (smartRemote or computer.uptime() >= cTime + 3)) then
|
||||
local _, _, direction = stargate.stargateState()
|
||||
if (direction == 'Outgoing') then
|
||||
if (not smartRemote) then
|
||||
stargate.openIris()
|
||||
else
|
||||
RemoteGate.openIris()
|
||||
end
|
||||
elseif (direction == 'Incoming' and not smartRemote) then
|
||||
--open iris for dumb connections
|
||||
stargate.openIris()
|
||||
end
|
||||
doOnce = false
|
||||
end
|
||||
local eventName, componentAddress, p1, p2, p3, p4, p5 = computer.pullSignal()
|
||||
if (eventName == 'sgMessageReceived') then
|
||||
onMessageReceived(p1, p2, p3, p4, p5)
|
||||
elseif (eventName == 'sgStargateStateChange') then
|
||||
if (p2 == 'Idle') then
|
||||
stargate.closeIris()
|
||||
smartRemote = false
|
||||
elseif (p1 == 'Idle') then
|
||||
stargate.openIris()
|
||||
smartRemote = false
|
||||
elseif (p1 == 'Connected') then
|
||||
RemoteGate.ping()
|
||||
doOnce = true
|
||||
cTime = computer.uptime()
|
||||
end
|
||||
end
|
||||
end
|
Reference in New Issue
Block a user