ID:2667168
 
Hey BYOND! With the newly available Steam integration, and with Hazordhu making use of a lot of the new functionality I thought I'd share the things that I'm learning and setting up with the rest of the community here. The first thing I've got more or less ironed out is a simple way to authenticate a client, using the new GetAPI() and CheckPassport() tools.

Here's the snippet. It's very simple, it just fetches info about the client and if you want to use this little snippet, just make sure that your values for SUB_PASSPORT STEAM_APP_ID and STEAM_DLC_ID1 are set properly.

// We do all of this on ye olde client object
client
// We store everything in an associated list for easy access later
var/tmp
credentials[] = list(
"byond_member" = FALSE,
"byond_subscriber" = FALSE,
"steam_name" = FALSE,
"steam_id" = FALSE,
"steam_passport" = FALSE,
"steam_dlc_1" = FALSE
)

proc
// We can call this proc to do a full authentication of permission levels
Authenticate()
return BYONDAuthentication() | SteamAuthentication()

// Let's say we want to give BYOND Members and Hub Subscribers the same authentication level
BYONDAuthentication()
credentials["byond_member"] = IsByondMember()
credentials["byond_subscriber"] = CheckPassport(SUB_PASSPORT)

// Either a valid membership or subscription will be considered authenticated
return credentials["byond_member"] || credentials["byond_subscriber"]

// Here we can grab and store values for our various Steam info
SteamAuthentication()
credentials["steam_name"] = GetAPI("steam", "name")
credentials["steam_id"] = GetAPI("steam", "id")
credentials["steam_passport"] = CheckPassport("steam:[STEAM_APP_ID]")
credentials["steam_dlc_1"] = CheckPassport("steam:[STEAM_DLC_ID1]")

// If they don't have their Steam Passport, we consider them not authenticated
return credentials["steam_passport"]


Easy as that. So let's say you have a part of your game that you only want accessible to hub subscribers:

client/New()
..()
Authenticate()

turf/subscriber_gate
Enter(atom/movable/am)
if(istype(am, /mob))
var/mob/m = am
return m.client?.credentials["byond_subscriber"]
// To change this to only allow Steam users, just change the index key!


And there we go. It's as easy as checking this list whenever you need to double check permissions, or update the credentials.
There's steam integration into DM? Did not know that!
Not a lot of people do so far! It's a new feature currently in the Beta cycle, but as I'm using it and getting my game ready for its steam release on Friday, I figured I would share what I'm learning to help other developers on their road to publishing their games outside of our little community!
Very helpful. Thanks for the information!