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

2012/4/4

Player Chat Possible!

DonaldDuck DonaldDuck

2012/4/4

#
After countless updates on multiple different scenarios, it's finally working. I'm excited to announce a player lobby where you can chat with other players! Check it out, talk to me, talk to anyone! Here is the link. True multiplayer action isn't supported by Greenfoot, but some sideways programming got it there.
nccb nccb

2012/4/4

#
The use of the score for recency is quite neat. One point: you're calling store() a lot more than you need to. The store() method stores the data to the server/file, but even without storing, getString() will return the result of the last setString(). In general, if you're calling store() more than once in any act cycle, you're calling it too many times (and if you're calling it every act() cycle, it's still too much -- but I don't think you are?). In particular, code like this:
p = PlayerData.getMyData();
            setText("");
            p.setString(0, null);
            p.store();
            p.setString(1, null);
            p.store();
            p.setString(2, null);
            p.store();
            p.setString(3, null);
            p.store();
            p.setString(4, null);
            p.store();
            p.setScore(2);
            p.store();
You don't need any of those except the final store(). The only time you might need multiple store() calls is if you use getTop or getNearby -- they will reflect the value of the last stored data, excluding local changes.
DonaldDuck DonaldDuck

2012/4/5

#
The score updating for recency was actually bourne's idea that I implemented recently. The store() method seemed to be not storing properly during my initial testing, but it must have been a different problem in the code. Thanks for the clarification!
You need to login to post a reply.