Jump to content


Photo

Using Playtomic API


  • Please log in to reply
43 replies to this topic

#31 ShaunS

ShaunS

    GMC Member

  • GMC Member
  • 92 posts
  • Version:Unknown

Posted 30 October 2012 - 01:15 PM

Hrm. I wrote this which as far as I can tell is more or less identical to the other functions but it isn't working. By 'isn't working' I mean I'm clicking my submit button and as far as I can tell it's crashing because it's not running the next line to change room, whereas if I comment out the function call it works.

Debugging HTML5 is hard :/
function Shauntomic_SaveAndList(pname, pscore, table)
{
	var simple_score = {};
    	simple_score.Name = pname
    	simple_score.Points = pscore
	
	scorelist = 0;
   	Playtomic.Leaderboards.SaveAndList(simple_score, table, crunchscores, null, {perpage: 10});
   	return scorelist;
}

  • 0

#32 Dangerous_Dave

Dangerous_Dave

    GMC Member

  • Global Moderators
  • 9406 posts
  • Version:Unknown

Posted 30 October 2012 - 11:21 PM

Did you remember to add the function into Studio?
  • 0

#33 ShaunS

ShaunS

    GMC Member

  • GMC Member
  • 92 posts
  • Version:Unknown

Posted 31 October 2012 - 10:35 AM

Did you remember to add the function into Studio?

Yeah. I pretty much copied the structure of the submit score function. Everything seems like it should work it's very hard to tell what I'm missing.

I tried even just copying the code over another function that was already added and set up but got the same problem. Implying something wrong with the javascript, my best guess is i've used the SaveAndList function wrongly or there's something inside that function that GameMaker doesn't like.
  • 0

#34 ShaunS

ShaunS

    GMC Member

  • GMC Member
  • 92 posts
  • Version:Unknown

Posted 31 October 2012 - 01:36 PM

So it didn't like:
Playtomic.Leaderboards.SaveAndList(simple_score, table, crunchscores, null, {perpage: 10});

But it accepted:
Playtomic.Leaderboards.SaveAndList(simple_score, table, crunchscores, {perpage: 10});

which successfully saves scores, but doesn't return them for some reason. I think I'm screwing something up with how this function should be set up but it reads:
Playtomic.Leaderboards.SaveAndList(score, table, callback, saveoptions, listoptions)

in the documentation..

vastly confused. Debugging this stuff feels like total guesswork haha.
  • 0

#35 Dangerous_Dave

Dangerous_Dave

    GMC Member

  • Global Moderators
  • 9406 posts
  • Version:Unknown

Posted 31 October 2012 - 09:29 PM

I'm sure I've successfully implemented that function before, I'll see if I can have a look at what I've got when I get home tonight, and post it for you.

Edit: Here you go, it's the GMZ of the game. Import into studio, then go and check out the gmx folder wherever you are keeping those (I think default is My Documents/GameMaker: Studio/Projects), then look at the extensions folder. The Davetomic.js script should be in a subfolder in there. That shows you how I set it up.

Although, the game itself still doesn't work at the moment, returning errors, but that may be to do with the changes since I first used playtomic and set up this extension.

Also the one you're using that's saving scores but not listing them, remember it's an asynchronous connection... you don't get the scores back straight away,you have to keep polling the callback function to check for them.

If you're still having problems, what error is the javascript console showing?

Edited by Dangerous_Dave, 01 November 2012 - 12:13 AM.

  • 0

#36 ShaunS

ShaunS

    GMC Member

  • GMC Member
  • 92 posts
  • Version:Unknown

Posted 01 November 2012 - 10:41 AM

I'm sure I've successfully implemented that function before, I'll see if I can have a look at what I've got when I get home tonight, and post it for you.

Edit: Here you go, it's the GMZ of the game. Import into studio, then go and check out the gmx folder wherever you are keeping those (I think default is My Documents/GameMaker: Studio/Projects), then look at the extensions folder. The Davetomic.js script should be in a subfolder in there. That shows you how I set it up.

Although, the game itself still doesn't work at the moment, returning errors, but that may be to do with the changes since I first used playtomic and set up this extension.

Also the one you're using that's saving scores but not listing them, remember it's an asynchronous connection... you don't get the scores back straight away,you have to keep polling the callback function to check for them.

If you're still having problems, what error is the javascript console showing?

Unless I'm being a complete mong I don't see a link or attatchment anywhere :o

Javascript console? If you mean the box that appears in debug mode it didn't show anything. That was the biggest problem. The only way I know there's been a problem is because hitting my submit scores button didn't take me to the next screen in HTML5 unless I commented out the SaveandList call. (And it was therefore able to reach the room_goto underneath) Either way i've since gotten the SaveandList call to at least not crash by just not passing either options object as 'null' (Even though the function seemed like it should handle that fine :S) and it will submit scores absolutely fine but will not return them. I do a poll every 15 or so frames.

I can return scores by clicking the leaderboards menu option which just uses List to get the scores, but running SaveandList with all the same parameters will save but not return any scores and will just sit in my 'Loading Scores' state indefinitely. (Indicating something wrong with the callback? Unsure how to get the function's response.error to print somewhere either incase that's the problem.) Which is very strange as the way the callback is set up inside the playtomic.js for each function is totally identical.

Edited by ShaunS, 01 November 2012 - 10:46 AM.

  • 0

#37 Dangerous_Dave

Dangerous_Dave

    GMC Member

  • Global Moderators
  • 9406 posts
  • Version:Unknown

Posted 01 November 2012 - 07:55 PM

I'm the mong, sorry, link: https://dl.dropbox.c...3/Davetomic.gmz

Most browsers have a javascript console. In Chrome, it's under Tools. Any time the game appears to freeze, you can bet there's a message there waiting for you.
  • 0

#38 ShaunS

ShaunS

    GMC Member

  • GMC Member
  • 92 posts
  • Version:Unknown

Posted 02 November 2012 - 01:51 PM

I'm the mong, sorry, link: https://dl.dropbox.c...3/Davetomic.gmz

Most browsers have a javascript console. In Chrome, it's under Tools. Any time the game appears to freeze, you can bet there's a message there waiting for you.



I still don't have it quite working but I just had the hour at lunch to mess about today.. I found the main reason for the crash though. Entertainingly the fault of the API, I was wondering why it didn't like having null passed for save options:

SaveAndList: function(score, table, callback, saveoptions, listoptions)
			{
				// common data
				var postdata = {};
				postdata.table = table;
				
				// save data
				var allowduplicates = saveoptions.allowduplicates || saveoptions.allowduplicates == false ? saveoptions.allowduplicates : false;
				var highest = saveoptions.highest || saveoptions.highest == false ? saveoptions.highest : true;
				var facebook = saveoptions.facebook || saveoptions.facebook == false ? saveoptions.facebook : false;
				
				if(saveoptions == null)
					saveoptions = new Object();

Tell me when you spot the hilarious problem with where the last two lines are >_>

explains why I've been getting all these

"Uncaught TypeError: Cannot read property 'allowduplicates' of undefined " errors

over and over.
  • 0

#39 ShaunS

ShaunS

    GMC Member

  • GMC Member
  • 92 posts
  • Version:Unknown

Posted 02 November 2012 - 10:00 PM

Posted Image

So all the crashes and unresponsive button issues seem to be solved. It's just a matter of working out why I'm not getting any score data back when I perform saveandlist vs list.

My best guess is that the api action saveandlist doesn't return the same data as list, since save also has a callback?

So maybe there's two kinds of data being returned for a saveandlist that need to be handled, the save response and the list data. *Shrug*

Edit: Well.. according to the API comments that's not the case. But looking into the network tab of the console, when I do a list, I get the following POST response:

{"Status": 1, "ErrorCode": 0, "Data": {"NumScores": 32,"Scores": [{"Name": "TVENTY","Points": "2206","Website": "127.0.0.1:51268","SDa................. etc

When I use SaveAndList I just get:

{"Status": 1, "ErrorCode": 0}

Which makes zero sense.

Edited by ShaunS, 02 November 2012 - 10:18 PM.

  • 0

#40 jonn

jonn

    GMC Member

  • GMC Member
  • 20 posts

Posted 13 November 2012 - 11:45 PM

Any progress on this?
I cant help with the harder coding but I can contribute with energy!

I tried today and I get views and plays. But i dont seem to get scores recorded. Is that the problem all of you have?

I got scores recorded aswell, at least on time. But my browsers are returning alot of errors

Edited by jonn, 14 November 2012 - 01:12 AM.

  • 0

#41 Dangerous_Dave

Dangerous_Dave

    GMC Member

  • Global Moderators
  • 9406 posts
  • Version:Unknown

Posted 14 November 2012 - 05:10 AM

I get various problems. I haven't had time to update the extension so it could well be out of date. I'm looking at updating this once the Playtomic V2 is released, since there may be some major changes meaning it will need a rewrite anyway.

My biggest problem is my lack of time, though, but I'll try my best to write a new version after the Playtomic V2 is released.
  • 0

#42 jonn

jonn

    GMC Member

  • GMC Member
  • 20 posts

Posted 14 November 2012 - 06:57 AM

Thanks for your efforts!
I hope you get around to it and a gladly help, if i could/can.
  • 0

#43 ShaunS

ShaunS

    GMC Member

  • GMC Member
  • 92 posts
  • Version:Unknown

Posted 16 November 2012 - 10:21 AM

I ended up settling for using the individual but functional saving and listing functions.

Definitely works, but there's some annoying stuff with scores coming back before they've updated and also playtomic not allowing me to overwrite a player's top score (Either no duplicates and no overwrite, or duplicates. Seems strange :|)

I think waiting on PTomic 2.0 is the best plan right now.
  • 0

#44 _178197

_178197

    GMC Member

  • GMC Member
  • 64 posts
  • Version:Unknown

Posted 01 December 2012 - 11:24 AM

Damn! The views is being logged but the highscore isn't being submitted. Please help me!
  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users