This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
Bionicles_rule's profile picture

Closing multishell tabs after finished

Started by Bionicles_rule, 23 April 2017 - 02:31 PM
Bionicles_rule #1
Posted 23 April 2017 - 04:31 PM
I am attempting to make a program that has computers using rednet to check usernames and passwords, I currently trying to make it so when it gets a rednet message it will open a multishell tab but when the it is finished I want it to close the tab.
Does anyone know a way to do this, I am currently trying to make it switch to the tab then terminate it but when I use multishell.getCurrent() in a tab launched by multishell it give me "attempt to index ?" when I tried this without creating the tab with multishell it works.
here is the code that is running in the tab

local args = {...}
local sender = args[1]
local message = args[2]

local s, m = rednet.receive()
if sender == s then
  rednet.send(sender,"Correct")
else
  print(sender)
  print(s)
end
multishell.getCurrent()
os.queueEvent("terminate")
and here is the code starting the tab

rednet.open("left")
while true do
local s, m = rednet.receive("First")
print("Gotten")
multishell.launch ({},"GetRednet",s,m)
end
does anyone know how to fix this or another way of closing the program?
Bomb Bloke #2
Posted 24 April 2017 - 01:40 AM
You're launching the tab with an empty environment table, depriving it of the "shell" and "multishell" "APIs" loaded into the starting tab's environment. You'd probably find it easier to use shell.openTab() instead, as this sorts out the environment side of things for you (it is to multishell.launch() as shell.run() is to os.run()).

I'm not sure what you're expecting multishell.getCurrent() to do, though. All it does is return a number - it doesn't change anything. I'm not actually sure why you're wanting to open additional tabs in the first place, for that matter?