At the moment I am doing something like
name = os.getComputerLabel()
if name == "1" or name == "2" or name =="3" then
...
elseif name =="4" then
...
end
--is it possible to do
c1 = 1,2,3
--and then
if name == c1 then
...
end
name = os.getComputerLabel()
if name == "1" or name == "2" or name =="3" then
...
elseif name =="4" then
...
end
--is it possible to do
c1 = 1,2,3
--and then
if name == c1 then
...
end
local names1 = {
["1"] = true;
["2"] = true;
["3"] = true;
}
local names2 = {
["4"] = true;
["5"] = true;
["6"] = true;
}
local label = os.getComputerLabel()
if names1[name] then
...
elseif names2[name] then
...
end
local function check(...)
for k,v in pairs({...}) do
if name == v then
return true
end
end
end
if check(1,2,3) then
elseif check(4) then
end
We could give you a better answer if you'd tell us what exactly you need it for. But with that kind of setup you could do it with tables:local names1 = { ["1"] = true; ["2"] = true; ["3"] = true; } local names2 = { ["4"] = true; ["5"] = true; ["6"] = true; } local label = os.getComputerLabel() if names1[name] then ... elseif names2[name] then ... end
No:+ You'll need to open the file, write the value down, and close the file every single time you move
local handle = fs.open("xy","w")
local function os.pullEvent(...)
local event = { os.pullEventRaw(...) }
if event[1] == "terminate" then
handle.close()
error("You pressed CTRL+T",0)
end
return unpack(event)
end
...
handle.close()
No:+ You'll need to open the file, write the value down, and close the file every single time you movelocal handle = fs.open("xy","w") local function os.pullEvent(...) local event = { os.pullEventRaw(...) } if event[1] == "terminate" then handle.close() error("You pressed CTRL+T",0) end return unpack(event) end ... handle.close()
Shutting down and rebooting automatically closes all file handlers.No:+ You'll need to open the file, write the value down, and close the file every single time you movelocal handle = fs.open("xy","w") local function os.pullEvent(...) local event = { os.pullEventRaw(...) } if event[1] == "terminate" then handle.close() error("You pressed CTRL+T",0) end return unpack(event) end ... handle.close()
What about CTRL+S and CTRL+R?
local file = fs.open( "wrong", "w" )
file.write( 1 )
file.write( 2 )
os.shutdown()
12