Cross-Resource Invocation
Using Elements, you can invoke a function across the network and access any function on any resource.
-- game_script.lua
...
function game_script.play_turn(player_id)
...
print (string.format("Player %s made a move!", player_id))
...
return game_info
end
...
-- Endpoint code
...
-- Payload is the resource id of the game in this example
function game_api.play_turn(payload, request, session)
local game_resource_id = payload
local player = auth.profile()
local player_id = player.id
local game_info, response_code = resource.invoke(game_resource_id, "play_turn", player_id)
return response.formulate(response_code, game_info)
end
...Last updated