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

Howd you make a rednet-enabled server?

Started by ry00000, 30 January 2016 - 05:09 PM
ry00000 #1
Posted 30 January 2016 - 06:09 PM
like, for example, a computer sends via rednet a string to the server and the server stores it in a file. (i.e logs it)
Lupus590 #2
Posted 30 January 2016 - 06:30 PM
have you looked at the computercraft wiki? if you scroll down to the bottom then you will get a list of all of the (default) APIs

to do your example you will need the rednet API and the fs API
Edited on 30 January 2016 - 05:33 PM
ry00000 #3
Posted 30 January 2016 - 06:56 PM
yeah, rednet and fs. Give me some example code plz.
Lupus590 #4
Posted 30 January 2016 - 09:19 PM

--#I have made no effort to make sure that this is valid lua
local file = fs.open(filepath,"a")
while true
  file.write(rednet.receive())
  file.flush()
end
Edited on 31 January 2016 - 01:15 PM
Waitdev_ #5
Posted 30 January 2016 - 11:50 PM

--#I have made no effert to make sure that this is valid lua
local file = fs.open(filepath,"a")
while true
  file.write(rednet.receive())
  file.flush()
end
i think you're forgetting some things:

file.close()
unless you're not gonna add a break to the program


while true do --#instead of while true
Edited on 30 January 2016 - 10:52 PM
Lupus590 #6
Posted 31 January 2016 - 02:15 PM

while true do --#instead of while true


--#I have made no effort to make sure that this is valid lua

and yes, you should close your file at some point
Edited on 31 January 2016 - 01:16 PM
ry00000 #7
Posted 31 January 2016 - 03:14 PM
I'm trying to make a bank. Should I store the stuff in a rednet server? And how do I program the turtle that will top up?
HPWebcamAble #8
Posted 31 January 2016 - 05:21 PM
I'm trying to make a bank. Should I store the stuff in a rednet server? And how do I program the turtle that will top up?

To make a bank program, you'd need a 'server' to save the account names,passwords, and balances of each user.

Then a client program would send requests to the server, like creating an account or transferring funds.

What does a turtle have to do with anything?
Lupus590 #9
Posted 31 January 2016 - 07:00 PM
What does a turtle have to do with anything?

at a guess, transporting items to and from the vault
ry00000 #10
Posted 05 February 2016 - 12:05 PM
No, it holds the items and puts them in a secure chest from industrialcraft 2.
wilcomega #11
Posted 05 February 2016 - 01:29 PM
Well you will need to store user data like username / password and balance on the server, then a computer with a client program connects to the server and asks the server to do something like transfer money, or deposit money. of course the security needs to be very good on these kinds of Servers as you dont want someone to order the server to transfer money from someones account to the hackers account. you should probably look into hashing the passwords and keeping log files.

there is also the problem of distinguising between regular clients and ATMS's, i dont know what sort of features you will have but these are some guidelines :)/>
Edited on 05 February 2016 - 12:32 PM