6 posts
Location
France
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.
2427 posts
Location
UK
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%29http://computercraft...ki/Fs_%28API%29
Edited on 28 March 2016 - 11:20 AM
6 posts
Location
France
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
2427 posts
Location
UK
Posted 28 March 2016 - 02:52 PM
for i in ipairs(tableName) do
--# something with tableName[i].name
end
6 posts
Location
France
Posted 28 March 2016 - 03:41 PM
Thank you.
1080 posts
Location
In the Matrix
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
6 posts
Location
France
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 ?
2427 posts
Location
UK
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
1080 posts
Location
In the Matrix
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.