Skip to content

Commit

Permalink
Added a bunch of new friends APIs
Browse files Browse the repository at this point in the history
Fixes #5
  • Loading branch information
britzl committed Nov 15, 2023
1 parent 8f6a66f commit e8becd2
Show file tree
Hide file tree
Showing 11 changed files with 961 additions and 38 deletions.
309 changes: 309 additions & 0 deletions api.json

Large diffs are not rendered by default.

134 changes: 134 additions & 0 deletions api.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,56 @@ Passed as parameter to the store



### EActivateGameOverlayToWebPageMode_Default [`EActivateGameOverlayToWebPageMode_Default`]
Passed as parameter to ActivateGameOverlayToWebPage



### EActivateGameOverlayToWebPageMode_Modal [`EActivateGameOverlayToWebPageMode_Modal`]
Passed as parameter to ActivateGameOverlayToWebPage



### EPersonaStateOffline [`EPersonaStateOffline`]
Friend is not currently logged on



### EPersonaStateOnline [`EPersonaStateOnline`]
Friend is logged on



### EPersonaStateBusy [`EPersonaStateBusy`]
User is on, but busy



### EPersonaStateAway [`EPersonaStateAway`]
Auto-away feature



### EPersonaStateSnooze [`EPersonaStateSnooze`]
Auto-away for a long time



### EPersonaStateLookingToTrade [`EPersonaStateLookingToTrade`]
Online, trading



### EPersonaStateLookingToPlay [`EPersonaStateLookingToPlay`]
Online, wanting to play



### EPersonaStateInvisible [`EPersonaStateInvisible`]
Online, but appears offline to friends. This status is never published to clients.



---

## steam_apps
Expand Down Expand Up @@ -112,6 +162,55 @@ RETURNS
* `String` [`name`] - Name of user


### friends_get_persona_name()
Returns the local players name - guaranteed to not be NULL. This is the same name as on the users community profile page. This is stored in UTF-8 format.


RETURNS
* `String` [`name`] - Name of user


### friends_get_persona_state()
Gets the status of the current user. Returned as EPersonaState.


RETURNS
* `Number` [`state`] - Status of user.


### friends_get_friend_persona_state(steamIDFriend)
Returns the current status of the specified user. This will only be known by the local user if steamIDFriend is in their friends list; on the same game server; in a chat room or lobby; or in a small group with the local user.


PARAMS
* `steamIDFriend` [`number`] - Id of friend

RETURNS
* `Number` [`state`] - State of friend


### friends_get_friend_steam_level(steamIDFriend)
Get friends steam level.


PARAMS
* `steamIDFriend` [`number`] - Id of friend

RETURNS
* `Number` [`level`] - Steam level of friend


### friends_get_friend_relationship(steamIDFriend)
Returns a relationship to a user.


PARAMS
* `steamIDFriend` [`number`] - Id of friend

RETURNS
* `Number` [`relationship`] - Relationship to the user.


### friends_activate_game_overlay_to_store(app_id,flag)
Activates game overlay to store page for app.

Expand All @@ -121,6 +220,15 @@ PARAMS
* `flag` [`number`] - EOverlayToStoreFlag


### friends_activate_game_overlay_to_web_page(url,mode)
Activates game overlay web browser directly to the specified URL. Full address with protocol type is required, e.g. http://www.steamgames.com/


PARAMS
* `url` [`string`] -
* `mode` [`number`] - EActivateGameOverlayToWebPageMode


---

## steam_listener
Expand Down Expand Up @@ -450,5 +558,31 @@ RETURNS
* `running_on_steamdeck` [`Boolean`] -


### utils_get_image_size(image)
Get size of image


PARAMS
* `image` [`number`] - Image handle

RETURNS
* `ok` [`Boolean`] - True if size of image was read successfully
* `width` [`Number`] - Image width or nil
* `height` [`Number`] - Image height or nil


### utils_get_image_rgba(image,size)
Get image in RGBA format.


PARAMS
* `image` [`number`] - Image handle
* `size` [`number`] - Size of image

RETURNS
* `ok` [`Boolean`] - True if size of image was read successfully
* `Image` [`String`] -


---

42 changes: 17 additions & 25 deletions examples/friends/friends.gui_script
Original file line number Diff line number Diff line change
Expand Up @@ -13,55 +13,47 @@ local FRIENDS = [[FRIENDS
]]

local function show_avatar(user_id, node)
local small_avatar_id = steamworks.friends_get_small_friend_avatar(user_id)
local ok, w, h = steamworks.utils_get_image_size(small_avatar_id)
local small_avatar_id = steam.friends_get_small_friend_avatar(user_id)
local ok, w, h = steam.utils_get_image_size(small_avatar_id)
if not ok then
print("Unable to get image size")
return
end

local b = buffer.create(w * h, {
{ name = "rgba", type = buffer.VALUE_TYPE_UINT8, count = 4 }
})
local ok = steamworks.utils_get_image_rgba(small_avatar_id, b, w * h * 4)
local ok, rgba = steam.utils_get_image_rgba(small_avatar_id, w * h)
if not ok then
print("Unable to get image RGBA")
return
end

local data = buffer.get_bytes(b, "rgba")
gui.new_texture(user_id, w, h, "rgba", data, false)
gui.new_texture(user_id, w, h, "rgba", rgba, false)
gui.set_texture(node, user_id)
gui.set_size(node, vmath.vector3(w, h, 0))
end

function init(self)
msg.post(".", "acquire_input_focus")

local status, error = pcall(steamworks.init)
local status, error = steam.init
if not status then print("Error: " .. error) return end

steamworks.set_listener(function(self, e, t)
steam.set_listener(function(self, e, t)
print(e)
pprint(t)
end)

local user_id = steamworks.user_get_steam_id()
local name = steamworks.friends_get_persona_name()
local state = steamworks.friends_get_persona_state()
local immediate_friends = steamworks.friends_get_friend_count(steamworks.FRIEND_FLAG_IMMEDIATE)
local user_id = steam.user_get_steam_id()
local name = steam.friends_get_persona_name()
local state = steam.friends_get_persona_state()
local immediate_friends = steam.friends_get_friend_count(steam.EFriendFlagImmediate)
show_avatar(user_id, gui.get_node("avatar"))

local names = ""
for i=0,immediate_friends-1 do
local fid = steamworks.friends_get_friend_by_index(i, steamworks.FRIEND_FLAG_IMMEDIATE)
local name = steamworks.friends_get_friend_persona_name(fid)
local state = steamworks.friends_get_friend_persona_state(fid)
local level = steamworks.friends_get_friend_steam_level(fid)
local relationship = steamworks.friends_get_friend_relationship(fid)

print("get follower count for", fid)
steamworks.friends_get_follower_count(fid)
local fid = steam.friends_get_friend_by_index(i, steam.EFriendFlagImmediate)
local name = steam.friends_get_friend_persona_name(fid)
local state = steam.friends_get_friend_persona_state(fid)
local level = steam.friends_get_friend_steam_level(fid)
local relationship = steam.friends_get_friend_relationship(fid)
names = names .. ("%s - %d (%s)\n"):format(name, level, personastate(state))
end

Expand All @@ -70,11 +62,11 @@ function init(self)
end

function final(self)
steamworks.final()
steam.final()
end

function update(self, dt)
steamworks.update()
steam.update()
end

function on_input(self, action_id, action)
Expand Down
3 changes: 1 addition & 2 deletions examples/menu/menu.gui_script
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@ function on_input(self, action_id, action)
monarch.show("user")
end)
rpg.button("friends", action_id, action, function()
print("Not implemented")
--monarch.show("friends")
monarch.show("friends")
end)
rpg.button("utils", action_id, action, function()
monarch.show("utils")
Expand Down
15 changes: 8 additions & 7 deletions examples/utils/personastate.lua
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
local M = {}

PERSONASTATES = {
[steamworks.PERSONA_STATE_OFFLINE] = "offline",
[steamworks.PERSONA_STATE_ONLINE] = "online",
[steamworks.PERSONA_STATE_BUSY] = "busy",
[steamworks.PERSONA_STATE_AWAY] = "away",
[steamworks.PERSONA_STATE_SNOOZE] = "snooze",
[steamworks.PERSONA_STATE_LOOKING_TO_TRADE] = "looking to trade",
[steamworks.PERSONA_STATE_LOOKING_TO_PLAY] = "looking to play",
[steam.EPersonaStateOffline] = "offline",
[steam.EPersonaStateOnline] = "online",
[steam.EPersonaStateBusy] = "busy",
[steam.EPersonaStateAway] = "away",
[steam.EPersonaStateSnooze] = "snooze",
[steam.EPersonaStateLookingToTrade] = "looking to trade",
[steam.EPersonaStateLookingToPlay] = "looking to play",
[steam.EPersonaStateInvisible] = "invisible",
}

function M.to_string(state)
Expand Down
Loading

0 comments on commit e8becd2

Please sign in to comment.