This site requires JavaScript, please enable it in your browser!
Greenfoot back
RcCookie
RcCookie wrote ...

2020/10/14

Saving a json file online

RcCookie RcCookie

2020/10/14

#
I'm trying to get some kind of multiplayer working where every player constantly updates a json-file with its coordinates, speeds and similar. It works on the greenfoot application (somewhat), but how can I use this online? Formatter does not work, I cannot save files, and my files have more than 50 characters so I cannot simply save it into the UserInfo class as a string. Does anyone know if and how I can store a bigger string online?
danpost danpost

2020/10/14

#
You might be surprised how much data can be stored with 250 (50 x 5 Strings) characters (plus 11 integers).
RcCookie RcCookie

2020/10/14

#
I am currently using smooth movement, which improves the smoothness when the connection is not so good. Also, when using UserInfo, every player has a different instance of that meaning that they can't access it
RcCookie RcCookie

2020/10/14

#
Also, multiplayer does not work properly online simply because threads don't work. Do you maybe know a workaround for that?
danpost danpost

2020/10/14

#
RcCookie wrote...
when using UserInfo, every player has a different instance of that meaning that they can't access it
I think you mean that only one UserInfo block can be edited during a single scenario execution. Am I correct (about what you mean)?
RcCookie RcCookie

2020/10/14

#
danpost wrote...
I think you mean that only one UserInfo block can be edited during a single scenario execution. Am I correct (about what you mean)?
No, what I mean is that there is no central storage, or a way to access a specific user's UserInfo, like "UserInfo.getUserInfoFor(playerName)".
danpost danpost

2020/10/14

#
RcCookie wrote...
No, what I mean is that there is no central storage, or a way to access a specific user's UserInfo, like "UserInfo.getUserInfoFor(playerName)".
No, there is not. Also, I could be wrong, but I am not too sure that UserInfo works properly on the site anymore. Anyway, locally, the data access time is way faster, and there is a way to list ALL blocks and find one with a specific user name.
RcCookie RcCookie

2020/10/14

#
You're right (somewhat), I'm just taking the first million (based on the url of my account, there shouldn't be more than 100000 users). However, I have fould UserInfo actually doing some weird stuff where if destroys its own save file and you manually have to insert a comma or remove a newline. But like I said above, even if you get it to work, it won't run smoothly without multiple threads, which don't seem to work online.
danpost danpost

2020/10/14

#
RcCookie wrote...
I'm just taking the first million (based on the url of my account, there shouldn't be more than 100000 users).
Ah, but noone has a block when a scenario that uses it is first uploaded. Only when the scenario first does a "store" on a user does that user get a block; and that user must be signed in even for that to happen. So you might, over time, accumulate 100+ UserInfo blocks on a scenario.
You need to login to post a reply.