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

[OpenPeripheralAddons] Logger

Started by Night_Fire, 28 March 2016 - 10:50 AM
Night_Fire #1
Posted 28 March 2016 - 12:50 PM
Hello. I'm trying to make a player logger with a sensor.

I know how to detect the players with the sensor but i don't know how to use tha table the sensor give me :


{
   {
	   uuid = "...",
	   name = "...",
   }
   {
	  uuid = "...",
	  name = "...",
   }
}

I would like to print each name on the computer and send them to another computer that will add it to a file call log.

Thanks for your help.
Lupus590 #2
Posted 28 March 2016 - 01:20 PM
Does this help?


{
   {
		   uuid = "...",
		   name = "...", --#access as tableName[1].name
   }
   {
		  uuid = "...",
		  name = "...", --#access as tableName[2].name
   }
}

http://computercraft...ednet_%28API%29
http://computercraft...ki/Fs_%28API%29
Edited on 28 March 2016 - 11:20 AM
Night_Fire #3
Posted 28 March 2016 - 02:01 PM
Oh yes, it helps a lot. Thank you.

And there a way to access to all the name with a single command ? Because the number of player is not the same each time.
Edited on 28 March 2016 - 12:06 PM
Lupus590 #4
Posted 28 March 2016 - 02:52 PM

for i in ipairs(tableName) do
  --# something with tableName[i].name
end
Night_Fire #5
Posted 28 March 2016 - 03:41 PM
Thank you.
Dragon53535 #6
Posted 29 March 2016 - 03:49 AM
Why give him half of what ipairs does?


for i,v in iapirs(tableName) do
  --# v is the same as tableName[i] so you can use v.name instead
end
Night_Fire #7
Posted 30 March 2016 - 12:56 PM
I think it will help me. Can i use "v" in order to send the table via rednet ?
Lupus590 #8
Posted 30 March 2016 - 01:29 PM
try it with a test program, if it works then great, if not then you can ask us for more help.

(this is part of programming, finding out if things will work when you have an idea.)

should it work?it should do, otherwise you have a bug
Edited on 30 March 2016 - 11:31 AM
Dragon53535 #9
Posted 31 March 2016 - 12:45 AM
If tableName works, then v should as well. Of course you could always rename i and v to whatever variables you want.