Hub

by Forum_account
[Documentation] [Share] [Zip]
To download this library for your Linux/Mac installation, enter this on your command line:

DreamDownload byond://Forum_account.Hub##version=4

Emulator users, in the BYOND pager go to File | Open Location and enter this URL:

byond://Forum_account.Hub##version=4

3795 downloads
Version 4
Date added: Dec 15 2011
Last updated: Jun 16 2012
4 fans
An easier way to manage BYOND's hub-based features. [More]
This library provides you with easy ways to manage medals and scores. For example:

// give the player a medal
client.AddMedal("Champion")

// get a list of the player's medals
var/list/medals = client.GetMedals()
for(var/m in medals)
world << m

// add 3 to the player's kill count
client.SetScore("kills", ADD, 3)

You can specify different operations in the SetScore proc so with a single proc call you can update the score however you'd like. You don't need to handle getting the current score, adding to it, then updating the scoreboard with the new score. That's all taken care of for you.

The library also provides you with a way to get information from a hub entry. You can get a list of servers that are publicly available:

var/list/servers = world.GetServers("Forumaccount", "AMinerAdventure")

for(var/Server/s in servers)
world << s.url

This makes it very easy to create an in-game list of servers the player can choose from.

Version History

Version 4 (posted 06-16-2012)
  • Changed the return values of the AddMedal and ClearMedal procs. They return 0 if the operation failed, 1 if the operation wasn't necessary (ex: you called AddMedal to give the player a medal they already had), and 2 if the operation was necessary and succeeded. This lets you still use the return value to determine whether the player has (or doesn't have) the medal and also gives you the ability to distinguish between cases where the player already had the medal and the case where they're getting it for the first time.
Version 3 (posted 03-15-2012)
  • Updated the world.GetServers proc to use savefiles to read the information returned by the BYOND hub.
  • Added the world.GetFans() proc, which returns a list of users who are fans of the specified hub entry. If no hub entry is specified, the proc uses world.hub.
Version 2 (posted 02-11-2012)
  • Made the world.GetServers proc accept a single string of the form "author.game". If you pass it one string it splits the string - everything before the period is the author and everything after it is the game's name.
  • Made the world.GetServers proc handle the case that no servers are running.
  • Added the score-demo example which shows how to abstract out the library to make hub scores even easier to use.
Version 1 (posted 12-15-2011)
  • Initial version.

More Info

Version 3 by Forum_account
Hub Library by Forum_account

Advertisement

Comments

Forum_account: (Feb 11 2012, 8:42 am)
I posted this library a while ago but forgot to make it visible. I think I was waiting for this bug to be addressed.

I just posted an update which improved the world.GetServers proc. Now these three calls are all the same:

world/hub = "Forumaccount.TestGame"

world.GetServers("Forumaccount", "TestGame")
world.GetServers("Forumaccount.TestGame")
world.GetServers() // no args means it'll use world.hub

I also added a demo called "score-demo" which shows a way to encapsulate the library calls in an object. You define the score's name and data type when you create the object and use its Add(), Max(), Set(), etc. procs to update the score.