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

ATM style system

Started by Rawkn_sawce, 22 July 2014 - 09:12 PM
Rawkn_sawce #1
Posted 22 July 2014 - 11:12 PM
So what I am trying to accomplish is making a currency system in minecraft through ComputerCraft.
I know it's been done before but I can't find any tutorials or web pages that explains what I need.

My main concern right now is making it so a new user can log in to the "ATM" and register an account.

Would I need a secondary computer/system running a server to accept the new input? Where do I store the users information so that it can be pulled again when he needs to log in to check his funds?
Cranium #2
Posted 22 July 2014 - 11:14 PM
It depends on what system you want. Do you have any code so far?
In general, one or more "server" computers are the ones handling the actual data, saving and updating accounts, and the rest are just access computers. You might look into using wired/wireless rednet to make a client/server system.
bigbrainiac10 #3
Posted 22 July 2014 - 11:47 PM
When I started making my bank system, I tried to make sure everything clientside, stays clientside. I also encrypted every single rednet message, and made sure my system was wired and behind safe walls (assuming your system is going to be protected by plugins)

I also used prefixes on messages like "REGISTER_USER", so the server knew before processing the data properly what it was dealing with.

All in all though, the actual money management side of it is fairly easy, it's just a lot of the Rednet and FS apis.
hilburn #4
Posted 23 July 2014 - 12:51 AM
I used the PIM from openperipherals when making my CCcurrency system as it allows you to quite easily identify the user through use of peripheral.getInventoryName() which will return the username of whoever is standing on it rther than having to deal with floppy disks or whatever
Rawkn_sawce #5
Posted 23 July 2014 - 01:36 AM
Well the idea is to have an actual economy through the MCDollar. So there won't be an infinite amount of money floating around to prevent inflation.

Next I want to allow users to be able to use floppy disks as a "bank card" or have the ability to log in through an account name.

So I would guess that when the user registers it would issue them an account number.

As far as code. The only thing I have is a bunch of print() etc stuff to set up the GUI. I'm not too experienced in computer craft and I learn better when I take on big projects above my skill level and I thought this would be a great place to start.

Mainly, I just want to see an example or for someone to explain to me the process of how I would be able to store input from a user trying to "register" into my system that can be accessed later through say, a login.

If I'm not being clear please let me know so I can try to elaborate more.
cptdeath58 #6
Posted 23 July 2014 - 02:37 AM
It would be good to use a multi-computer system so you can store the user's files in a secure area while the ATM processes the requests.
Rawkn_sawce #7
Posted 23 July 2014 - 02:09 PM
I'm assuming that through using a secondary computer to run as a server, it would have to be reset everytime the minecraft server reset seeing as the computers turn off when chunks unload. So a server restart would technically unload the whole world.

I have this newcomers post restriction on my account so this post is basically a bump so that my second post can be acknowledged since it posted it at the original time I sent the request. Thank you all do your time
Neywiny #8
Posted 24 July 2014 - 01:06 AM
well here's what I would do and have done
using the fs api, make a server computer that has a file called users, and then as you may expect, if you know the fs api, you'd append (write at the end of the document, on the next line) something like this:
USER=Rawken_SawsPIN=0909BAL=1337
then you would open the file, and each line would go into a new line of a table like so:

x=1
while true do
tUsersOld[x]=fs.readLine()
if tUsersOld[x]=nil then
break
else
x = x+1
end
end
then you would out those raw lines into a new table, like tUsersNew, and have it as an array with each piece of data as it's own line in the array, using string.find then string.sub, which would split the string.
Rawkn_sawce #9
Posted 24 July 2014 - 05:09 AM
well here's what I would do and have done
using the fs api, make a server computer that has a file called users, and then as you may expect, if you know the fs api, you'd append (write at the end of the document, on the next line) something like this:
USER=Rawken_SawsPIN=0909BAL=1337
then you would open the file, and each line would go into a new line of a table like so:

x=1
while true do
tUsersOld[x]=fs.readLine()
if tUsersOld[x]=nil then
break
else
x = x+1
end
end
then you would out those raw lines into a new table, like tUsersNew, and have it as an array with each piece of data as it's own line in the array, using string.find then string.sub, which would split the string.

You make my brain hurt, thank you for the help. I will do some research into the fs api.