Posted 11 August 2013 - 07:18 PM
This is a small program i wrote to convert the labels.txt file into a serialized table that can then be used for whatever.
i wrote it because all the computers i have are named and some of them run the client side code for my computercraft mainframe which needs to be able to tell the user what computer they are on, and which server/relay they are connected to, but more importantly, tell the server which command came from where. below is the pastebin link and some example code.
Pastebin: Nn2xNY8x
Example code:
if you are going to use this in the way i am (the client software is in the rom folder so people cant edit it and i don't need to manually change 50 copies of the code if i make changes) then having the whois file in the rom folder is problem because this program wont be able to update the whois file.
the solution? create a symlink to the whois file on the computer of your choice :)/>
i wrote it because all the computers i have are named and some of them run the client side code for my computercraft mainframe which needs to be able to tell the user what computer they are on, and which server/relay they are connected to, but more importantly, tell the server which command came from where. below is the pastebin link and some example code.
Pastebin: Nn2xNY8x
Example code:
File = fs.open("rom/WhoIs", "r")
Table = File.readAll()
WhoIs = textutils.unserialize(Table)
File.close() --close the file
if WhoIs == nul then
error("whois file is empty")
end
MyName = WhoIs[os.computerID()] --set myname to the value associated with os.computerID() (e.g. 1)
if MyName == "" then -- if myname is empty
MyName = "Unknown" --then set myname to unknown
end
--end of that bit
clear()
sleep(1)
print("This is computer: ", os.computerID(), " (", MyName, ")")
if you are going to use this in the way i am (the client software is in the rom folder so people cant edit it and i don't need to manually change 50 copies of the code if i make changes) then having the whois file in the rom folder is problem because this program wont be able to update the whois file.
the solution? create a symlink to the whois file on the computer of your choice :)/>