Skip to content

Add trophies, track player's play time and sessions, and connect to GameJolt with this project!

Notifications You must be signed in to change notification settings

TentaRJ/GameJolt-FNF-Integration

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

30 Commits
 
 
 
 
 
 

Repository files navigation

GameJolt FNF Integration

This project is designed to be used with Friday Night Funkin. This allows you to add trohies in your GameJolt gamepage and award them to the user along with adding scores to leaderboard tables!

Included in the repo is the API to add trophies and the state (GameJoltLogin) to sign the user in.

Have any issues? Report them to the repo via Github Issues!

-tenta

PLANS:

REQUIREMENTS:

I will be editing the API for this, meaning you have to download my custom haxelib library, tentools.

You also need to download and rebuild Haya's version of systools.

Run these in the terminal:

haxelib git tentools https://github.com/TentaRJ/tentools.git
haxelib git systools https://github.com/haya3218/systools
haxelib run lime rebuild systools [windows, mac, linux]

If you are going to be releasing the source code of a mod with this integration, you need to place a few things into Project.xml.

Place these into Project.xml:

<haxelib name="tentools" />
<haxelib name="systools" />
<ndll name="systools" haxelib="systools" />

Once that is all done, you can place GameJolt.hx into the source/ folder of your project!

SETUP (GAMEJOLT):

Make sure to add import GameJolt; at the top of main.hx!

To add your game's keys, you will need to make a file in the source folder named GJKeys.hx (filepath: ../source/GJKeys.hx).
In this file, you will need to add the GJKeys class with two public static variables, id:Int and key:String.

source/GJKeys.hx example:

package;
class GJKeys
{
    public static var id:Int = 	0; // Put your game's ID here
    public static var key:String = ""; // Put your game's private API key here
}

DO NOT SHARE YOUR GAME'S API KEY! You can add source/GJKeys.hx to a .gitignore file to make sure no one grabs the key! If someone gets it, they can send false data!

You can find your game's API key and ID code within the game page's settngs under the game API tab.

SETUP (TOASTS):

Thank you Firubii for the code for this! Please go check them out!

https://twitter.com/firubiii / https://github.com/firubii

To setup toasts, you will need to do a few things.

Inside the Main class (Main.hx), you need to make a new variable called toastManager.

Main.hx

public static var gjToastManager:GJToastManager;

Inside the setupGame function in the Main class, you will need to create the toastManager.

gjToastManager = new GJToastManager();
addChild(gjToastManager);

TYSM Firubii for your help!

USAGE:

Make sure to put import GameJolt.GameJoltAPI; at the top of the file if you want to call a command!

import GameJolt.GameJoltAPI;

These commands must be ran before starting the API. Place these in TitleState.hx:

GameJoltAPI.connect();
GameJoltAPI.authDaUser(FlxG.save.data.gjUser, FlxG.save.data.gjToken);

Username and Token are grabbed from the default FlxG.save file. This file can be changed in TitleState.hx.

Exiting the login menu will throw you back to Main Menu State. You can change this in the GameJoltLogin class inside GameJolt.hx.

The session will automatically start on login and will be pinged every 30 seconds. If it isn't pinged within 120 seconds, the session automatically ends from GameJolt's side.

You can open the login state by calling the GameJoltLogin state:

FlxG.switchState(new GameJoltLogin());

PSYCH ENGINE SUPPORT STEP's

1.Install Tentools, Systools and rebuild systools

2.Setup GameJolt

3.Put the thing's on Main.hx and TitleState.hx

PS: You should have internet connection for login, just that

CHANGABLE VARIABLES:

GameJoltInfo.changeState:FlxUIState

The state you will call back to after hitting ESCAPE or CONTINUE

GameJoltInfo.font:String

The font used in GameJoltLogin

GameJoltInfo.fontPath:String

The font path used for the notifications

GameJoltInfo.imagePath:String

The file path for the image in the notifications.

COMMANDS AVAILABLE:

GameJoltAPI.getStatus():Bool

Checking to see if the user has signed in. Returns a bool value. true if signed in, false if not signed in.

GameJoltAPI.getuserInfo(username):String

Grabs the username and usertoken of the user and returns a String.
username:Bool = true -> true to grab username, false to grab usertoken.

GameJoltAPI.getTrophy(trophyID);

TrophyID:Int -> ID of the trophy you want the player to earn.

GameJoltAPI.checkTrophy(trophyID);

Returns a bool value of the achieved status. True for achieved, false for not achieved.
TrophyID:Int -> ID of the trophy you want to check.

GameJoltAPI.pullTrophy(trophyID);

Returns a Map<String,String> of the trophy called for.
TrophyID:Int -> ID of the trophy you want to pull.

GameJoltAPI.addScore(score:Int, tableID:Int, ?extraData:String);

Adds a score to a table on GameJolt.
score:Int -> The score to add. Will also count as the sorting value.
tableID:Int -> ID of the table.
extraData:String -> Exta data you want to add. Could be accuracy, who knows.

GameJoltAPI.pullHighScore(tableID:Int)

Pulls the data from the highest score on the table. Will return a Map<String,String> value.
tableID:Int -> ID of the table.
Values returned -> score, sort, user_id, user, extra_data, stored, guest, success

CREDITS:

About

Add trophies, track player's play time and sessions, and connect to GameJolt with this project!

Resources

Stars

Watchers

Forks

Languages