Quick Links: Download Gideros Studio | Gideros Documentation | Gideros Development Center | Gideros community chat | DONATE
How to use "Gaming" plugin? — Gideros Forum

How to use "Gaming" plugin?

rrraptorrrraptor Member
edited September 2016 in General questions
I spent a lot of time to compile my application. Finally, it does not crush on line
require "gaming"
Now it's crushing here:
require "gaming"
googleplay = Gaming.new("googleplay")
Gaming.login()
googleplay:addEventListener(Event.LOGIN_ERROR, self.loginComplete, self)
googleplay:addEventListener(Event.LOGIN_COMPLETE, self.loginError, self)
Android Studio log says: "MenuScene.lua.jet:178: bad argument #1 to 'login' (Gaming expected, got no value)"
So, what should i pass to that login method??? And am I use plugin correctly?
«13

Comments

  • hgy29hgy29 Maintainer
    By the look of the error, login expects a Gaming object to be passed as first arg, so I would call it that way:
    googleplay:login()
  • Nope.
    Gaming.login(googleplay)
    That how it works. Again, wasted a lot of time to find out how to use this plugin, cuz no docs...
  • totebototebo Member
    edited September 2016
    The API for each plugin can be found in the install.html file.

    To activate the Gaming plugin:
    require "gaming"
    To activate Google Play on Android:
    self.gameServices = Gaming.new( "googleplay" )
    To activate GameKit on iOS:
    self.gameServices = Gaming.new( "gamekit" )
    To log in:
    self.gameServices:addEventListener( Event.LOGIN_COMPLETE, self.onLoginComplete, self )
    self.gameServices:addEventListener( Event.LOGIN_ERROR, self.onLoginError, self )
    self.gameServices:login()
    This is the Gaming plugin API:

    API Reference

    Methods

    • Gaming.new(framework) -- initialize specified framework
    • Gaming.login(param1, param2, ..., paramn) -- authenticate user
    • Gaming.logout() -- logout user
    • Gaming:showLeaderboard(id) --show leader board window (string leaderboard id)
    • Gaming:showAchievements() --show achievements window
    • Gaming:reportScore(id, score, immediate) --report new score (string leaderboard Id, number score, bool immediate (true will usually provide events))
    • Gaming:reportAchievement(id, steps, immediate) --report new achievement (string achievement Id, number steps - progress of achievement, bool immediate (true will usually provide events))
    • Gaming:loadAchievements() --load list of achievements, raises LOAD_ACHIEVEMENTS_COMPLETE or LOAD_ACHIEVEMENTS_ERROR
    • Gaming:loadScores(id) --load list of scores for leaderboard Id, raises LOAD_SCORES_COMPLETE or LOAD_SCORES_ERROR
    • Gaming:loadState(key) --numeric key, raised STATE_LOADED or STATE_ERROR
    • Gaming:updateState(key, data[, immediate]) --update data, numeric key, can raise STATE_CONFLICT or STATE_ERROR
    • Gaming:deleteState(key) --delete data for numeric key, can raise STATE_DELETED or STATE_ERROR
    • Gaming:resolveState(key, version, data) --resolve state conflict for slot key with version and data, should be called if STATE_CONFLICT event was dispatched, may raise STATE_LOADED event for new resolved data

    Events

    • Event.LOGIN_COMPLETE
    • Event.LOGIN_ERROR
      • e.error - error message
    • Event.LOAD_ACHIEVEMENTS_COMPLETE
      • event.achievements
      • event.achievements[].id
      • event.achievements[].name
      • event.achievements[].description
      • event.achievements[].status
      • event.achievements[].currentSteps
      • event.achievements[].totalSteps
      • event.achievements[].lastUpdate
    • Event.LOAD_ACHIEVEMENTS_ERROR
      • e.error - error message
    • Event.REPORT_ACHIEVEMENT_COMPLETE
      • e.id -- achievement id
    • Event.REPORT_ACHIEVEMENT_ERROR
      • e.id -- achievement id
      • e.error - error message
    • Event.LOAD_SCORES_COMPLETE
      • event.name -- leader board name
      • event.id -- leader board ID
      • event.scores
      • event.scores[].name
      • event.scores[].timestamp
      • event.scores[].score
      • event.scores[].rank
      • event.scores[].playerId
    • Event.LOAD_SCORES_ERROR
      • e.error - error message
      • e.id -- leader board ID
    • Event.REPORT_SCORE_COMPLETE
      • e.id - leaderboard id
      • e.score -- score reported
    • Event.REPORT_SCORE_ERROR
      • e.id - leaderboard id
      • e.score -- score reported
      • e.error -- error message

    Cloud Events

    • Event.STATE_LOADED
      • event.key
      • event.data
    • Event.STATE_ERROR
      • event.key
    • Event.STATE_CONFLICT
      • event.key
      • event.version
      • event.localData
      • event.serverData
    • Event.STATE_DELETED
      • event.key
    Link on the Gaming plugin installation and API on Github:

    https://github.com/gideros/gideros/blob/master/plugins/gaming/install.html

    Likes: MoKaLux

    My Gideros games: www.totebo.com
    +1 -1 (+1 / -0 )Share on Facebook
  • rrraptorrrraptor Member
    edited September 2016
    @totebo i know, but as you can see:
    Gaming.login(param1, param2, ..., paramn) -- authenticate user
    What is the param???
    And why u are using like this:
    self.gameServices:login()
    When docs says:
    Gaming.login(param1, param2, ..., paramn)
    And btw, my method works fine ( Gaming.login(googleplay) )
    P.S. no need to copy whole file data here :/

  • totebototebo Member
    edited September 2016
    Hey @rraptor,

    It works both ways; you use the Gaming class directly, I use an instance of the initiated class. If you use the Gaming class directly, you have to always send the instance to it as a first parameter. This can get confusing, which is why I prefer to work with the instance instead.

    For instance, when you load high scores you would have to write it like this if you use the class directly:
    Gaming:showLeaderboard( googleplay, id )
    Whereas if you used the instance you would write:
    googleplay:showLeaderboard( id )
    Hope this makes sense.

    The "param1, param2" from the docs indicate there may be parameters per specific network. Google Play doesn't require a parameter for its login method.


    I copied and pasted the API because of your "Again, wasted a lot of time to find out how to use this plugin, cuz no docs" comment. :)

    Likes: MoKaLux

    My Gideros games: www.totebo.com
    +1 -1 (+1 / -0 )Share on Facebook
  • Maybe the documentation could be like not named "how to use this plugin" instead of "install" ;)

    Likes: totebo

    +1 -1 (+1 / -0 )Share on Facebook
  • rrraptorrrraptor Member
    edited September 2016
    It works both ways
    Ok, now i know :D
    And i know about those "install.html" files in "All plugins" folder, but those docs could be a little bit better than it is now.
    For example, instead of
    Gaming.login(param1, param2...paramn)
    write
    Gamin:login()
    Dot and colon - two different things.
    And of course, fix the installation part, cuz it dint help much.

    Oh, and btw, can someone explain how to show multiple leaderboards? I have 4 (because 4 difficulties), and i want to load menu (from GP services) where player can select one of four leaderboards. Right now, i can show only first leaderboard (well, i can pass the id to "loadScores" method and load any other, but that's what i don't need) . Is it possible?
  • @antix, yeah I agree it could be easier to find the docs. I reckon after the automated export plugins work properly, each plugin should be added to the official docs online, with code examples.

    @rrraptor, the Gaming.login() and instance:login() is a Lua thing (rather than a Gideros thing), and it has confused me no end over the years. Starting to half-understand it now, buy it's still confusing.

    Not sure I understand what you mean about "choosing your score". If you're looking for a drop down to select the score, or just four buttons, that's something you have to code. And as for choosing high scores in general, iOS recently removed the functionality to display specific high score tables, so it would only work on Google Play anyway. If you want to manually load the scores for a specific table and manually display them on screen, that's still possible with loadScores().
    My Gideros games: www.totebo.com
  • @totebo
    i have 4 different tables in GP console:
    image
    Now, how to display menu where player can select a table he needs? Like this one:
    image
    I believe that it was made by using GP services.
  • totebototebo Member
    edited September 2016
    If you just leave the ID parameter blank when calling showScores() Google Play will display all high scores in the order you set when you created them on the Google Play dashboard.

    As far as I know Google Play don't allow you to add high score boards into sub-categories.
    My Gideros games: www.totebo.com
  • rrraptorrrraptor Member
    edited September 2016
    If you just leave the ID parameter blank when calling showScores() Google Play will display all high scores in the order you set when you created them on the Google Play dashboard.
    Nope. It didnt work. App just crushing.
  • totebototebo Member
    edited September 2016
    If you still want to use the Gaming class directly, instead of using its instance, you have to include the instance as the first parameter; Gaming.showScores(googleplay). I would recommend using the instance instead; googleplay:showScores().
    My Gideros games: www.totebo.com
  • can i use googleplay plugin api method from the gaming plugin (googleplay) instance?
    such as
    self.gameServices = Gaming.new( "googleplay" )
    self.gameServices:getPlayerScore() --this is a googleplay plugin method
  • With the Gaming plugin, you have to use its abstracted API. I believe to load scores there is a loadScores() method.
    My Gideros games: www.totebo.com
  • l7777777bl7777777b Member
    edited October 2016
    @totebo actually i want to get the player high score from the leaderboard and then save it to local if the player had played it before. based on the reference doc looks like it will get all the score, but i only need the current player score just like this method does (googleplay:getPlayerScore()). any clue for that?
  • I'm afraid not, although I did do this on one of my previous games. I think I used the separate plugins for iOS and Android to make it work, rather than the Gaming plugin.
    My Gideros games: www.totebo.com
  • totebo said:

    I'm afraid not, although I did do this on one of my previous games. I think I used the separate plugins for iOS and Android to make it work, rather than the Gaming plugin.

    Guys, in 'Gaming' plugin there's achievements functionality.
    Gaming:loadAchievements() --load list of achievements
    I don't see how to create achievements?
    If we don't create, then what achievements does it load?
    Something global from Google Play?
    > Newcomers roadmap: from where to start learning Gideros
    "What one programmer can do in one month, two programmers can do in two months." - Fred Brooks
    “The more you do coding stuff, the better you get at it.” - Aristotle (322 BC)
  • olegoleg Member
    edited August 2018
    здається я це бачив в настройках старої версії гуглплей апі
    my games:
    https://play.google.com/store/apps/developer?id=razorback456
    мій блог по гідерос https://simartinfo.blogspot.com
    Слава Україні!
  • olegoleg Member

    image.png
    1332 x 625 - 94K

    Likes: Apollo14

    my games:
    https://play.google.com/store/apps/developer?id=razorback456
    мій блог по гідерос https://simartinfo.blogspot.com
    Слава Україні!
    +1 -1 (+1 / -0 )Share on Facebook
  • olegoleg Member
    @Apollo14 як розберешся, напиши в блог "для чайників" покроково як інтегрувати в гру рекорди і досягнення і як налаштувати це в консолі
    my games:
    https://play.google.com/store/apps/developer?id=razorback456
    мій блог по гідерос https://simartinfo.blogspot.com
    Слава Україні!
  • oleg said:

    @Apollo14 як розберешся, напиши в блог "для чайників" покроково як інтегрувати в гру рекорди і досягнення і як налаштувати це в консолі

    okey dokey B)
    > Newcomers roadmap: from where to start learning Gideros
    "What one programmer can do in one month, two programmers can do in two months." - Fred Brooks
    “The more you do coding stuff, the better you get at it.” - Aristotle (322 BC)
  • Apollo14Apollo14 Member
    edited August 2018
    Guys, why I can't basically login? (I'm testing it on Android player with 'gaming' plugin included)
    All I have in my 'main.lua':
    require"gaming"; googleplay = Gaming.new("googleplay")
     
    googleplay:login()
     
    googleplay:addEventListener(Event.LOGIN_COMPLETE, function()
    	print"LOGIN COMPLETE"
    end)
     
    googleplay:addEventListener(Event.LOGIN_ERROR, function(event)
    	print("LOGIN ERROR:", event.error)
    end)
    I'm getting:
    main.lua is uploading.
    Uploading finished.
    LOGIN ERROR:	Could not sign in
    My plugin settings:
    image


    my android player's package name is 'com.mydomain.gplayer'
    while in 'Google Play console' -> 'Game services' I've written package name 'com.mydomain.anotherapp'

    We can't test googleplay gaming services on Gideros Android Player when package names differ?
    gaming_plugin_error_login.png
    600 x 401 - 38K
    > Newcomers roadmap: from where to start learning Gideros
    "What one programmer can do in one month, two programmers can do in two months." - Fred Brooks
    “The more you do coding stuff, the better you get at it.” - Aristotle (322 BC)
  • hgy29hgy29 Maintainer
    No, because google auth is based on package name. You need to make a specific player with your end app's package name, or declare your player's package in your google play console/game services

    Likes: Apollo14

    +1 -1 (+1 / -0 )Share on Facebook
  • Apollo14Apollo14 Member
    edited August 2018
    hgy29 said:

    No, because google auth is based on package name. You need to make a specific player with your end app's package name, or declare your player's package in your google play console/game services

    Okay now I've added new app to my GooglePlay console/game services (attached 3 screenshots)
    Then I've exported Gideros Android player with package name "com.strongsun.gplayer", that I've written in the console.

    But I'm receiving the same "LOGIN ERROR: Could not sign in".
    What else do I need to do? Upload gideros android player apk to developers console?
    001.png
    1876 x 393 - 48K
    002.png
    1565 x 937 - 79K
    003.png
    1875 x 619 - 74K
    > Newcomers roadmap: from where to start learning Gideros
    "What one programmer can do in one month, two programmers can do in two months." - Fred Brooks
    “The more you do coding stuff, the better you get at it.” - Aristotle (322 BC)
  • You need to upload an apk to google play, it can be an alpha.
    Coder, video game industry veteran (since the '80s, ❤'s assembler), arrested - never convicted hacker (in the '90s), dad of five, he/him (if that even matters!).
    https://deluxepixel.com
  • Two things that might help:

    1. Export as production .apk, with a keystore that isn't debug
    2. Enable Google drive in the Google Play console. I had to do this to make logins work the other day. Mysterious and undocumented.

    Likes: Apollo14

    My Gideros games: www.totebo.com
    +1 -1 (+1 / -0 )Share on Facebook
  • hgy29hgy29 Maintainer
    totebo said:


    2. Enable Google drive in the Google Play console.

    How do you do that in google play console ?
  • Bloody good question. @antix can you remember where you get to this option?
    My Gideros games: www.totebo.com

  • werwe.PNG
    1449 x 693 - 75K
    my games:
    https://play.google.com/store/apps/developer?id=razorback456
    мій блог по гідерос https://simartinfo.blogspot.com
    Слава Україні!
Sign In or Register to comment.