To access a function on a resource, we invoke that function across the network. To do this, we need to have the id of the resource, the name of the method, and any parameters we want to pass through, like so:
resource.invoke(resource_id, method, ...)
If we were to add to the above example to allow the player to invoke a play_turn function, it might look like this:
-- 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 ...