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

Show a list of active users?

Started by Beatsleigher, 02 April 2013 - 11:53 AM
Beatsleigher #1
Posted 02 April 2013 - 01:53 PM
Hello guys,

I was wondering if there is a way to actively show a list of users connected to my server.

I am currently hosting a hamachi-based server for private and YouTube let's play use (CraftToMineLP) and we want to do some subscriber events, like every time we reach +20 (in example) subs, we'd invite them to our server to play with us.

So I wanted to create an applet which actively shows a list of currently active users.

But I'm a complete n00b to Lua and I need some help - I don't even know if such a thing is possible - I can just about ask users stuff,


Io.write("Would you like to show the To-Do program?")
Answer=io.read()
If answer=="Y" then
monitor top ToDo
Elseif answer=="N" then
clear
print "Select a program from the list below"
print "1. Example"
print "2. Example2"
Program=io.read
if program=="1" then
monitor top Example
Elseif program=="2" then

and so on, but that's kind of the basic basics..

Any help and code would be much appreciated!

Thanks, Beatsleigher.
SuicidalSTDz #2
Posted 02 April 2013 - 01:58 PM
First order of business:
Lua is case sensitive

io.write instead of Io.write
if instead of If
and so on
Beatsleigher #3
Posted 02 April 2013 - 02:01 PM
First order of business:
Lua is case sensitive

io.write instead of Io.write
if instead of If
and so on

Oh. Ok. Sorry 'bout that. I'm used to VB and batch, which aren't case-sensitive. Thanks!
SuicidalSTDz #4
Posted 02 April 2013 - 02:03 PM
First order of business:
Lua is case sensitive

io.write instead of Io.write
if instead of If
and so on

Oh. Ok. Sorry 'bout that. I'm used to VB and batch, which aren't case-sensitive. Thanks!
It's a common mistake, especially if you are used to a non case-sensitive language.

As for getting the list of users on a server, i'm not quite sure you can without intensive coding behind minecraft in Java.
Beatsleigher #5
Posted 02 April 2013 - 02:04 PM
First order of business:
Lua is case sensitive

io.write instead of Io.write
if instead of If
and so on

Oh. Ok. Sorry 'bout that. I'm used to VB and batch, which aren't case-sensitive. Thanks!
It's a common mistake, especially if you are used to a non case-sensitive language.

Yeah, I can imagine :)/> I'm very thankful that you gave me that tip, if it weren't for you, it'd thrown errors and I'd be pretty clueless about it :x
SuicidalSTDz #6
Posted 02 April 2013 - 02:07 PM
Here is a great place to go if you aren't sure about correct syntax
oeed #7
Posted 02 April 2013 - 02:10 PM
As far as I am aware, this isn't possible with out any external blocks. You could use the new command blocks, I'm not really sure how to use them, but you could test for the amount of people online, or something like that.
SuicidalSTDz #8
Posted 02 April 2013 - 02:15 PM
As far as I am aware, this isn't possible with out any external blocks. You could use the new command blocks, I'm not really sure how to use them, but you could test for the amount of people online, or something like that.
There is a peripheral that emits redstone if any players are on the server already. Command blocks might work as well.
Beatsleigher #9
Posted 02 April 2013 - 02:17 PM
As far as I am aware, this isn't possible with out any external blocks. You could use the new command blocks, I'm not really sure how to use them, but you could test for the amount of people online, or something like that.

Hm. I should have mentioned this, but I'm using Tekkit Classic 3.1.2 - So no command blocks.

Which external blocks can I use?
theoriginalbit #10
Posted 02 April 2013 - 02:18 PM
you could use OpenCCSensors (OCS)… but that has a radius on it… nothing that I know of that does the whole server…

hmmm Tekkit Classic… you still have ccSensors then… same deal as OCS except that OCS was updated…
SuicidalSTDz #11
Posted 02 April 2013 - 02:23 PM
Blah! Tekkit <_</> Nagging men smoke, don't breathe this!
Beatsleigher #12
Posted 02 April 2013 - 02:26 PM
Blah! Tekkit <_</> Nagging men smoke, don't breathe this!

Tekkit isn't that bad :)/> It doesn't lag as much as vanilla and Tekkit Lite :D/>
SuicidalSTDz #13
Posted 02 April 2013 - 02:28 PM
Meh, I don't know what lag is.. I've never experienced it first-hand ^_^/>
Beatsleigher #14
Posted 02 April 2013 - 02:40 PM
Meh, I don't know what lag is.. I've never experienced it first-hand ^_^/>

Wow. I'm forced to play with ~11FPS :(/>
SuicidalSTDz #15
Posted 02 April 2013 - 02:42 PM
That is when you generally start to worry, thus leading to the purchase of a $3,000 computer..

On topic: So either use CCSensors or.. yeah. Learn Java :)/>
Beatsleigher #16
Posted 02 April 2013 - 02:49 PM
That is when you generally start to worry, thus leading to the purchase of a $3,000 computer..

On topic: So either use CCSensors or.. yeah. Learn Java :)/>

Yeah, I know :)/> I really need an upgrade, my PC is nine years old :o/>

I am already pleanning to learn Java, as I'm a member in the XDA communities and I'd like to program for Android. But, yeah.

Thanks for your help. There's just one other thing:

In "startup" I've written a bit of code, namely:


io.write("Would you like to load the the To-Do program?")
answer=io.read()
if answer=="Y" then
run monitor top ToDo

(The rest of the code is unimportant)

and whenever I reboot the computer or type "startup" is gives me following error:
bios:206: [string "startup"]:4: '=' expected.

Some help with that would be awesome, as well!
SuicidalSTDz #17
Posted 02 April 2013 - 03:15 PM
There is no need to use io.read() since cc reveals it's own read() function
Beatsleigher #18
Posted 02 April 2013 - 03:21 PM
There is no need to use io.read() since cc reveals it's own read() function

Ok. Got rid of that, but I'm still getting that error. No ideas?
SuicidalSTDz #19
Posted 02 April 2013 - 03:26 PM
Are you using the answer varaible for anything else? If not just do this:


write("Would you like to load the the To-Do program?")
if read() =="Y" then
run monitor top ToDo
Also, CC also reveals it's own write function, I highly suggest using it. There are other alternatives besides write such as term.write() and print()
Beatsleigher #20
Posted 02 April 2013 - 03:27 PM
Are you using the answer varaible for anything else? If not just do this:

write
("Would you like to load the the To-Do program?")
if read() == "Y" then
run monitor top ToDo

Also, CC also reveals it's own write function, I highly suggest using it. There are other alternatives besides write such as term.write() and print()

Yes, I am. There is "Y" and "N".
remiX #21
Posted 02 April 2013 - 09:51 PM
How did you miss this Suicidal?

run monitor top ToDo
->
shell.run( 'monitor', 'top', 'ToDo' )

When you wanting to run an external program and you're not in the terminal, you need to use shell.run