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

Startup Program

Started by Magicantrust, 10 January 2013 - 03:08 AM
Magicantrust #1
Posted 10 January 2013 - 04:08 AM
Hey there!
I write a startup routine, using basic commands. All runs fine BUT it never detects if a label is already set.
I think i cant use "os.getComputerLabel()" as bool variable, is there anything else i could use to detect it ?
My Code below


print ("This computers ID : "..os.getComputerID())
if os.getComputerLabel() ~= true then
print ("This Computer has no label")
print ("Do you want to label it now ?")
print (" Y / N ")
local a1 = read()
if a1 == "Y" then
shell.run("clear")
print ("Enter label : ")
local a2 = read()
os.setComputerLabel(a2)
print( "Your computer is now known as : " .. os.getComputerLabel() )
else
shell.run("clear")
end
else
print( "Name: " .. os.getComputerLabel() )
print( "welcome!")
sleep(2)
end
remiX #2
Posted 10 January 2013 - 04:11 AM
Compare it with nil to find if it is there is a label or not.


if os.getComputerLabel() == nil then -- you can also use if not os.getComputerLabel() then
  -- Doesn't have a label
else
  -- has a label
end
Magicantrust #3
Posted 10 January 2013 - 04:19 AM
Seems to work thanks alot :)/>