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

printing a turtle ID

Started by goldensecret, 24 February 2014 - 01:38 PM
goldensecret #1
Posted 24 February 2014 - 02:38 PM
hey, i am trying to write my first program. and its for the startup of my turtels, it is supposed to say 'hello my name is (get id) and my fuel level is (get fuel level) but i don't know how to make a turtle get its own id, since i set id's on all my turtles, and give them names like Barry, Bernard. dig_bik and such. i was just going to re do the code each time i get the startup pastebin, but thought i should dive deeper than that. here is the code as of current, and what i am aiming for

currently:
http://pastebin.com/MZ5r2S0D

what my aim is:
http://pastebin.com/501YkzpU

thanks in advance.
Lyqyd #2
Posted 24 February 2014 - 02:50 PM
os.getComputerLabel() will return the label of the computer if one is set.
Alice #3
Posted 24 February 2014 - 03:43 PM
os.getComputerLabel() will return the label of the computer if one is set.
I believe he asked for ID, but it's basically the same code c:
os.getComputerID() returns the computer's ID
Agoldfish #4
Posted 24 February 2014 - 03:51 PM
So to sum it up;

local Id = os.getComputerID()
print(Id)
plazter #5
Posted 24 February 2014 - 04:13 PM

print("Hello my name is wilson, i got ", turtle.getFuelLevel() , " Fuel currently. and my ID is: ", os.getComputerID())

That should do i think :D/>
Lyqyd #6
Posted 24 February 2014 - 05:08 PM
os.getComputerLabel() will return the label of the computer if one is set.
I believe he asked for ID, but it's basically the same code c:
os.getComputerID() returns the computer's ID

If you read the post more carefully, he uses the word ID, but talks about labels he has set on them.
goldensecret #7
Posted 26 February 2014 - 05:49 PM
os.getComputerLabel() will return the label of the computer if one is set.
I believe he asked for ID, but it's basically the same code c:
os.getComputerID() returns the computer's ID

If you read the post more carefully, he uses the word ID, but talks about labels he has set on them.
was that not correct? im sorry, i didnt realise they were diffrent things, i want to do label set wilson, and in the startup code, it prints its label, instead of me entering it manually every time.
goldensecret #8
Posted 26 February 2014 - 06:22 PM
right! i got it, thank you very much people :)/> a great help. heres the final product!

http://pastebin.com/GG3UcLax