Jump to content




Closing multishell tabs after finished


1 reply to this topic

#1 Bionicles_rule

  • New Members
  • 1 posts

Posted 23 April 2017 - 03: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?

#2 Bomb Bloke

    Hobbyist Coder

  • Moderators
  • 7,099 posts
  • LocationTasmania (AU)

Posted 24 April 2017 - 12: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?





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users