1 EU = 4 RF
EDIT: im being a derp sorry
There have been 32 items by plazter (Search limited from 10-February 22)
Posted by
plazter
on 31 August 2016 - 05:41 PM
in
Ask a Pro
Anavrins, on 31 August 2016 - 05:36 PM, said:
plazter, on 31 August 2016 - 04:19 PM, said:
function import()
local datafile = fs.open("whitelist", "r")
for name in datafile.readLine do
table.insert(whitelist, name:lower())
whitelist[name] = true
end
end
Posted by
plazter
on 31 August 2016 - 04:19 PM
in
Ask a Pro
Anavrins, on 31 August 2016 - 01:21 AM, said:
local whitelist = {} for name in file.readLine do whitelist[name] = true end When checking for a user in the whitelist, instead of using a loop like in Rockets example, you can simply index the name from the whitelist if whitelist[name] then -- Is in whitelist else -- Not in whitelist end
function import()
local datafile = fs.open("whitelist", "r")
for name in datafile.readLine do
table.insert(whitelist, name:lower())
whitelist[name] = true
end
end
and then where i lookfunction auth()
for k,result in pairs(s.getPlayers()) do
local name = result.name:lower()
if whitelist[name] then
print("ok")
else
print("nope")
end
end
end
Posted by
plazter
on 30 August 2016 - 05:08 PM
in
Ask a Pro
-snip-
for t,result in ipairs(s.getPlayers()) do
local name = result.name:lower()
for i = 1,#whitelist do
if name == whitelist[i] then
rs.setOutput("left", true)
end
end
end
rs.setOutput("left", false)
end
Posted by
plazter
on 30 August 2016 - 04:33 PM
in
Ask a Pro
Anavrins, on 30 August 2016 - 04:27 PM, said:
-snip- for line in datafile.readLine() do table.insert(whitelist, line) end -snip-You were on the right path with this, remove the () after "readLine", and this code will put each individual line of the file in "whitelist"
Posted by
plazter
on 30 August 2016 - 04:09 PM
in
Ask a Pro
function Authorised()
for k, v in pairs(s.getPlayers()) do
for p, playerName in pairs(v) do
for i = 1,#whitelist[i] do
if playerName:lower() == whitelist[i] then
print("Allowed: ".. playerName)
end -- if
end --for
end --for
end --for
end --function
Posted by
plazter
on 30 August 2016 - 01:46 PM
in
Ask a Pro
Quote
--# After declaration of `datafile` local line = datafile.readLine() while line do table.insert(whitelist, line) line = datafile.readLine() end --# whatever else
Posted by
plazter
on 30 August 2016 - 01:06 PM
in
Ask a Pro
houseofkraft, on 30 August 2016 - 01:01 PM, said:
local whitelist = nil
file = fs.open("whitelist", "r")
whitelist = file.readLine()
file.close()
Posted by
plazter
on 30 August 2016 - 01:01 PM
in
Ask a Pro
houseofkraft, on 30 August 2016 - 12:49 PM, said:
-snip-
local event, side, x, y = os.pullEvent("mouse_click")
if x >= 19 and x < 26 and y == 14 then
term.clear()
end
-snip-
Posted by
plazter
on 30 August 2016 - 12:50 PM
in
Ask a Pro
-snip- for line in datafile.readLine() do table.insert(whitelist, line) end -snip-
s = peripheral.wrap("right")
signal = "left"
whitelist = {}
state = false
function list()
if fs.exists("whitelist") == false then
shell.run("edit whitelist")
else
print("whitelist allready exist!")
end
end
function getList()
local datafile = fs.open("whitelist", "r")
for line in datafile.readLine() do
table.insert(whitelist, line)
end
datafile.close()
print(whitelist[1])
end
function Authorised()
for k, playerName in ipairs(s.getPlayers()) do
for p, o in ipairs(playerName) do
for _, name in ipairs(whitelist) do
if playerName:lower() == name:lower() then
state = true
end
end
end
end
state = false
end
function sig()
if state then
rs.setOutput(side, state)
else
rs.setOutput(side, state)
end
end
list()
getList()
while true do
sig()
sleep(1)
end
function Authorised() for k, v in pairs(s.getPlayers()) do for p, playerName in pairs(v) do for i = 1,#whitelist[i] do if playerName:lower() == whitelist[i] then --Do something here end -- if end --for end --for end --for end --function
Posted by
plazter
on 23 August 2016 - 02:47 PM
in
Ask a Pro
Dragon53535, on 23 August 2016 - 02:44 PM, said:
local num = rs.getBundledOutput("right")
num = num - 256
rs.setBundledOutput("right",num)
Quote
Posted by
plazter
on 23 August 2016 - 02:41 PM
in
Ask a Pro
Posted by
plazter
on 23 August 2016 - 02:36 PM
in
Ask a Pro
Dragon53535, on 23 August 2016 - 02:25 PM, said:
if(colors.test(rs.getBundledOutput("right"),colors.green)) then
--#If the input from the right has the color green on.
end
You can use this to setup an if-else statement in which it tests for colors that are on/off.
Posted by
plazter
on 23 August 2016 - 02:14 PM
in
Ask a Pro
col = {
[1] = 0, -- Inactive
[2] = 1, -- White
[3] = 2, -- Orange
[4] = 4, -- Magenta
[5] = 8, -- Light Blue
[6] = 16, -- Yellow
[7] = 32, -- Lime
[8] = 64, -- Pink
[9] = 128, -- Gray
[10] = 256, -- Light Gray
[11] = 512, -- Cyan
[12] = 1024, -- Purple
[13] = 2048, -- Blue
[14] = 4096, -- Brown
[15] = 8192, -- Green
[16] = 16384, -- Red
[17] = 32768, -- Black
}
on = {}
function getOn()
for i = 1,#col do
if rs.getBundledOutput("right") == col[i] then
table.insert(on, col[i])
end
end
end
getOn()
for i = 1,#on do
print(on[i])
end
input = read()
if input then
if input == "white" then
if not on == col[1] then
for i = 1,#on do
rs.setbundledOutput("right", col[2]+on[i])
end
else
rs.setBundledOutput("right", col[2])
end
end
if input == "green" then
if not on == col[1] then
for i = 1,#on do
rs.setbundledOutput("right", col[2]+on[i])
end
else
rs.setBundledOutput("right", col[15])
end
end
if input == "red" then
if not on == col[1] then
for i = 1,#on do
rs.setbundledOutput("right", col[2]+on[i])
end
else
rs.setBundledOutput("right", col[16])
end
end
end
Posted by
plazter
on 12 April 2016 - 06:53 PM
in
Ask a Pro
Lupus590, on 12 April 2016 - 06:37 PM, said:
-- full function
local function printEntry(t, m)--t is tankInfo, m is monitor
for _,a in pairs(t) do
m.print("name: "..a.contents.name)
m.print("amount: "..a.contents.amount)
end
end
Posted by
plazter
on 12 April 2016 - 04:54 PM
in
Ask a Pro
tank = {peripheral.find("rcsteeltankvalvetile")}
tankInfo = tank[1].getTankInfo()
tankInfoTwo = tank[2].getTankInfo()
tankInfoThree = tank[3].getTankInfo()
tankInfoFour = tank[4].getTankInfo()
tankInfoFive = tank[5].getTankInfo()
tankInfoSix = tank[6].getTankInfo()
monOne = peripheral.wrap("back")
monTwo = peripheral.wrap("monitor_276")
local function nLineOne()
lineOne = lineOne+1
monOne.setCursorPos(1,lineOne)
end
local function nLineTwo()
lineTwo = lineTwo+1
monTwo.setCursorPos(1,lineTwo)
end
-- tank one
while true do
monOne.clear()
monOne.setCursorPos(1,1)
monTwo.clear()
monTwo.setCursorPos(1,1)
lineOne = 1
lineTwo = 1
for _,a in pairs(tankInfo) do
for o,c in pairs(a.contents) do
monOne.write(o..": ".. c)
nLineOne()
end
end
nLineOne()
-- tank two
for _,b in pairs(tankInfoTwo) do
for o,c in pairs(b.contents) do
monOne.write(o..": ".. c)
nLineOne()
end
end
nLineOne()
--tank three
for _,d in pairs(tankInfoThree) do
for o,c in pairs(d.contents) do
monOne.write(o..": "..c)
nLineOne()
end
end
--tank four
for _,e in pairs(tankInfoFour) do
for o,c in pairs(e.contents) do
monTwo.write(o..": "..c)
nLineTwo()
end
end
nLineTwo()
for _,f in pairs(tankInfoFive) do
for o,c in pairs(f.contents) do
monTwo.write(o..": ".. c)
nLineTwo()
end
end
nLineTwo()
--tank Six
for _,g in pairs(tankInfoSix) do
for o,c in pairs(g.contents) do
monTwo.write(o..": ".. c)
nLineTwo()
end
end
sleep(.5)
end
Posted by
plazter
on 12 April 2016 - 03:45 PM
in
Ask a Pro
Sewbacca, on 12 April 2016 - 03:39 PM, said:
plazter, on 12 April 2016 - 03:28 PM, said:
tank = peripheral.wrap("back")
tankInfor k,v in pairs(tankInfo) do
for o,c in pairs(v) do
for a,b in pairs(c) do
print(a)
end
end
end
tank = peripheral.wrap("back")
tankInfo = tank.getTankInfo()
for _, t in pairs(tankInfo) do
for k,v in pairs(t.contents) do
--Your stuff
end
end
Posted by
plazter
on 12 April 2016 - 03:36 PM
in
Ask a Pro
tank = peripheral.wrap("back")
tankInfo = tank.getTankInfo()
for k,v in pairs(tankInfo) do
for o,c in pairs(v) do
if c == "contents" then
for a,b in pairs(c) do
print(a..": ".. B)/>
end
end
end
end
Posted by
plazter
on 12 April 2016 - 03:28 PM
in
Ask a Pro
tank = peripheral.wrap("back")
tankInfo = tank.getTankInfo()
for k,v in pairs(tankInfo) do
for o,c in pairs(v) do
for a,b in pairs(c) do
print(a)
end
end
end
{
{
capacity = 56000000
contents = {
rawName = "Lava",
amount = 256300
name = "lava",
id = 2,
},
},
}
Posted by
plazter
on 27 March 2016 - 07:22 AM
in
Ask a Pro
Dragon53535, on 27 March 2016 - 06:23 AM, said:
monitors[1].write(turbines[1].getActive()) --#Should be monitors[1].write(turbines[i].getActive())At the same time, I would first make sure that such values exist.
if (turbines[i] and turbines[i].getActive) then monitors[1].write(turbines[i].getActive()) endIf nothing prints out then we know for a fact that you're for some reason not getting properly wrapped turbines, or that they don't have a .getActive method
