62GB
|
  |
| Joined: 03 Oct 2011 |
| Total Posts: 4157 |
|
|
| 23 Oct 2015 01:23 PM |
| At one point I am going to need to access random keys from a datastore. Can I have some guidance / advice on how to achieve so? It seems difficult, yet maybe not. I'm not really sure how to start off, though. Any tips would be wonderful! |
|
|
| Report Abuse |
|
|
| |
|
|
| 23 Oct 2015 01:25 PM |
I would suggest a hot bath and a turkey sandwich.
ADORABLE BISQUE |
|
|
| Report Abuse |
|
|
62GB
|
  |
| Joined: 03 Oct 2011 |
| Total Posts: 4157 |
|
|
| 23 Oct 2015 01:31 PM |
| Well, if you ever played Clash of Clans or Boom Beach, they access other people's bases. All the bases are going to be saved in one Datastore. One base for each player (key). When I'm gonna create the attacking phase, I need to know how to get a random player (key) from said datastore. And thereby I can access that chosen key's data to load the base to attack. I don't know how to go about this, though. It makes great sense to me, but I don't know how to actually go about and do it. |
|
|
| Report Abuse |
|
|
eLunate
|
  |
| Joined: 29 Jul 2014 |
| Total Posts: 13268 |
|
|
| 23 Oct 2015 01:40 PM |
Make a key which has all the keys in it
I already told you this. |
|
|
| Report Abuse |
|
|
62GB
|
  |
| Joined: 03 Oct 2011 |
| Total Posts: 4157 |
|
|
| 23 Oct 2015 01:42 PM |
| ^ Don't know how. :/ /: ;/ |
|
|
| Report Abuse |
|
|
eLunate
|
  |
| Joined: 29 Jul 2014 |
| Total Posts: 13268 |
|
|
| 23 Oct 2015 01:46 PM |
You know how to make your keys when you save the player data You know how to save data
What could be so hard? Do you understand how to use a table? |
|
|
| Report Abuse |
|
|
62GB
|
  |
| Joined: 03 Oct 2011 |
| Total Posts: 4157 |
|
|
| 23 Oct 2015 01:51 PM |
| I'm more of a hands-on learner. If I see something I adapt to it. Can you show me a small example so I can get the point? |
|
|
| Report Abuse |
|
|
eLunate
|
  |
| Joined: 29 Jul 2014 |
| Total Posts: 13268 |
|
|
| 23 Oct 2015 01:53 PM |
No.
If I show you how to fix it, you'll come back in a week with the same problem. If I teach you how to fix it, you'll learn to use your brain before looking to us. |
|
|
| Report Abuse |
|
|
62GB
|
  |
| Joined: 03 Oct 2011 |
| Total Posts: 4157 |
|
|
| 23 Oct 2015 02:00 PM |
| why do i even come here any more |
|
|
| Report Abuse |
|
|
UFAIL2
|
  |
| Joined: 14 Aug 2010 |
| Total Posts: 6905 |
|
|
| 23 Oct 2015 02:03 PM |
| You use the datastore and don't know how to do this... If the key's are userId's save them to another DS in a table and pick a random value. |
|
|
| Report Abuse |
|
|
62GB
|
  |
| Joined: 03 Oct 2011 |
| Total Posts: 4157 |
|
|
| 23 Oct 2015 02:08 PM |
?
for i,v in pairs(DataStore) do print(v) end
Like that? xD
Idk... |
|
|
| Report Abuse |
|
|
62GB
|
  |
| Joined: 03 Oct 2011 |
| Total Posts: 4157 |
|
|
| 23 Oct 2015 02:16 PM |
Aw, I don't think you can do that. It looks like you can, though, based on how DataStores look like on roblox' 'datastore structures'
:c |
|
|
| Report Abuse |
|
|
Casualist
|
  |
| Joined: 26 Jun 2014 |
| Total Posts: 4443 |
|
|
| 23 Oct 2015 02:19 PM |
| Use an ordered datastore, key can equal the player's key and the value could be their level or something you matchmaking is easier. |
|
|
| Report Abuse |
|
|
62GB
|
  |
| Joined: 03 Oct 2011 |
| Total Posts: 4157 |
|
|
| 23 Oct 2015 02:21 PM |
But I don't even know how to grab a random value from a datastore. Would that work with pairs or something.. It's hardd |
|
|
| Report Abuse |
|
|
Casualist
|
  |
| Joined: 26 Jun 2014 |
| Total Posts: 4443 |
|
|
| 23 Oct 2015 02:29 PM |
Iterate through all the pages in the ordered store
Throw them in a table 'temp'
key = temp[math.random(1, #temp) |
|
|
| Report Abuse |
|
|
62GB
|
  |
| Joined: 03 Oct 2011 |
| Total Posts: 4157 |
|
|
| 23 Oct 2015 03:01 PM |
| That does make sense! So, I'll use OrderedDataStores to save the bases. I just remembered the global leaderboard stuff.. Thanks, I'll check into this. |
|
|
| Report Abuse |
|
|
62GB
|
  |
| Joined: 03 Oct 2011 |
| Total Posts: 4157 |
|
|
| 23 Oct 2015 03:42 PM |
'Dictionary is not allowed in Datastore'
What do you propose I do now? |
|
|
| Report Abuse |
|
|
Casualist
|
  |
| Joined: 26 Jun 2014 |
| Total Posts: 4443 |
|
|
| 23 Oct 2015 04:23 PM |
Save their base to a data store, note the key.
Using that key, save their level or something (must be an int) to the ordered data store. Then when you iterate through all the pages of the datastore you can sort out people whose level are too high or low for matchmaking and do what I said previously to get a random player from that dataset. |
|
|
| Report Abuse |
|
|
62GB
|
  |
| Joined: 03 Oct 2011 |
| Total Posts: 4157 |
|
| |
|