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

Store Player's "card data" in an in-game DB?

Started by Ashton, 12 July 2013 - 12:38 AM
Ashton #1
Posted 12 July 2013 - 02:38 AM
As I've mentioned before, I'm building a server that acts as a central Survival MC game, then portals take the player to other (pre-built) adventure maps where they can acquire special items/blocks…

Unfortunately, I dont want the player to retain ALL the items from the maps… so my current setup is a command-block that uses /clear to empty the player's inventory, then /give to return the item/block to them, and finally a /tpx to send them back to the "overworld" (survival game)

This works untill I started implimenting a non-linear dungeon system… because now I have every player with an RFID that tracks which areas are unlocked and which are not… and if they leave the adventure map, they lose all their progress…

So is there a way to create a DB-program that, when a player exits the world (at pre-determiend points, not just randomly) their progress is saved off the RFID before it's destroyed, and when they return, a new RFID is supplied with a /give then the old data is loaded onto it? (It sounds really easy to me, but I'm not familiar enough with LUA to implement it… especially with multiple "world exits" that have to sync the DB with the "world entrance")

All the DB needs is "Player Name" and "Card Data" (though if there's a way to record inventory/equipment that would also be nice to add, so it's a true "save state")


Pre-post-edit:
I remembered that I can cheat in multiple copies of a single disk using NBT Edit, so I think I can sync the DBs if I can make all updates write to the disk, but still not sure how to create the DB itself…
Lyqyd #2
Posted 16 July 2013 - 01:26 PM
Have a computer read the data off of the RFID when they approach the portal and write the data to disk. If you add something like OpenCCSensors, you can read the player name as well, for multiplayer purposes.
MxHn #3
Posted 22 July 2013 - 12:18 AM
As Lyqyd said, read the data off the card and write it using io API or fs API(persistance many ways to do including the famous table). Also you may want to consider a central data server computer(all "clients(portal controls)" send via modems to) for recording your data(that depends on your setup,I assume you have one computer per portal?)(Hope your map is in one demention)(May require editing the modem_range cfgs). I Think openccsensors can read inventories although you should clarify with someone who has played with the addon more.