Posted 10 October 2012 - 04:09 PM
RedControl
RedControl is little application made for controlling Redstone via RedNet. Client computer is locked with password.
Code:
GitHub:
https://github.com/j...r/RednetControl
Or copypasta:
Client:
Server:
To do:
RedControl is little application made for controlling Redstone via RedNet. Client computer is locked with password.
Code:
GitHub:
https://github.com/j...r/RednetControl
Or copypasta:
Client:
Spoiler
local pullEventBackup = os.pullEvent
os.pullEvent = os.pullEventRaw
--[[
Some rights reserved (CC-BY-NC-SA).
More info about it can be fount here: http://crteativecommons.org
Coded by jesusthekiller - github.com/jesusthekiller
]]
--CONFIG--
local password = "pass" --password?
local serverID = 1337 --server ID, shows up on server screen :P/>/>
local modemSide = "back" --side of modem
--END OF CONFIG, DO NOT EDIT BELOW THIS LINE--
local function clear()
term.clear()
term.setCursorPos(1,1)
print("ID of this computer: " .. os.computerID())
end
local function printLoginMessage()
print([[
Password:
-----------
]])
end
while true do
clear()
printLoginMessage()
term.setCursorPos(21,3)
if read("x") == password then
clear()
print("Redstone request has been sent.")
rednet.open(modemSide)
rednet.send(serverID, "doOpen")
rednet.close(modemSide)
sleep(2)
clear()
printLoginMessage()
else
clear()
print("Wrong Password!")
sleep(2)
printLoginMessage()
end
end
Server:
Spoiler
local pullEvent = os.pullEvent
os.pullEvent = os.pullEventRaw
--[[
Some rights reserved (CC-BY-NC-SA).
More info about it can be fount here: http://crteativecommons.org
Coded by jesusthekiller - github.com/jesusthekiller
]]
--CONFIG--
local clientID = { --Allowed cilent ID's. Separate lines with commas.
[1] = 33,
[2] = 1337,
}
local modemSide = "bottom" --Side of modem
local redstoneSide = "back" --Side of redstone output
local timeout = 3 --Timeout of redstone pulse in seconds
--NOT DONE YET
--local makeLog = true --Do server will log to file?
--END OF CONFIG, DO NOT EDIT BELOW THIS LINE--
local function clear()
term.clear()
term.setCursorPos(1,1)
print("ID of this server: " .. os.computerID())
end
local function open(id)
rs.setOutput(redstoneSide, true)
print("Opening signal from " .. id)
sleep(timeout)
rs.setOutput(redstoneSide, false)
print("Closing...")
end
local function main()
local senderID, message = rednet.receive()
for i=1,#clientID do
if senderID == clientID[i] and message == "doOpen" then
--logToFile(senderID, message)
open(clientID[i])
end
end
end
clear()
rednet.open(modemSide)
if redstoneSide == modemSide then
print("Error: redstoneSide is equal to modemSide. Check your config.")
end
while true do
main()
end
To do:
- Logging to file
- Make option to toggle redstone instead of pulse