Thanks a lot Scruffy. also im new at Lua!
If you want the code just ask! :3
local lbl = os.getComputerLabel()
term.setCursorPos(1,1) -- change this to where you want it to print
write(lbl)
print(os.getComputerLabel())
write(os.getComputerLabel())
local comp = os.getComputerLabel()
if comp ~= null then
-- print or write comp.
print(comp)
end
I agree with luanub. This is very basic stuff.
You could do either,print(os.getComputerLabel()) write(os.getComputerLabel())
I agree with luanub. This is very basic stuff.
You could do either,print(os.getComputerLabel()) write(os.getComputerLabel())
And if you think you might forget to label a computer and run this program.local comp = os.getComputerLabel() if comp ~= null then -- print or write comp. print(comp) end
term.setCursorPos(1,1)
term.write(os.getComputerLabel() or 'unlabeled')
I just want to add that you can also take this exception in account by doing it like this:term.setCursorPos(1,1) term.write(os.getComputerLabel() or 'unlabeled')
string lbl = os.getComputerLabel();
system.println(lbl != null ? lbl : "Unlabeled");
I'm pretty sure that's right, haven't used that in a while. Lol.I agree with luanub. This is very basic stuff.
You could do either,print(os.getComputerLabel()) write(os.getComputerLabel())
And if you think you might forget to label a computer and run this program.local comp = os.getComputerLabel() if comp ~= null then -- print or write comp. print(comp) end
I agree with luanub. This is very basic stuff.
You could do either,print(os.getComputerLabel()) write(os.getComputerLabel())
And if you think you might forget to label a computer and run this program.local comp = os.getComputerLabel() if comp ~= null then -- print or write comp. print(comp) end
Also, in Lua, we use nil, not null.
oooooOOOhh Thank you!I just want to add that you can also take this exception in account by doing it like this:term.setCursorPos(1,1) term.write(os.getComputerLabel() or 'unlabeled')
Haven't done much OOP in lua/CC yet. It's kind of limited in that regard.
In regards to that post I was referring to ComputerCraft.Haven't done much OOP in lua/CC yet. It's kind of limited in that regard.
Read the Lua Manual, specifically the portion on metatables in Part 2 which leads into OO. The syntax will take some time to get used to, but Lua is far from being 'limited'.
i would have too!I meant inside computercraft. I give up. Lol.