In services/server/player/player_service.lua
there are a number of functions. One of these functions, get_host_player_id_command
is called by ui/root/js/stonehearth/stonehearth_client.js
as follows:
radiant.call_obj('stonehearth.player', 'get_host_player_id_command')
.done(function(e) {
self.gameState.hostPlayerId = e.player_id;
});
I try to do something similar for a different function in there, but I can’t seem to do it:
radiant.call_obj('stonehearth.player', 'are_player_ids_hostile', playerID, self._playerID)
.done(function (e) {
self._isHostile = e.response;
});
Looking more closely at the lua, I can see the function I’m calling should simply be returning a boolean, while the other function includes a response parameter that then gets set in the function, rather than directly returning a value: response:resolve({ player_id = _radiant.sim.get_host_player_id() })
Does radiant.call_obj(...)
only work for functions that are set up in this particular way? It wants to return a deferred object that, in the case of my function, never gets resolved (I set a breakpoint on the relevant line, and it never breaks).
So does this mean I have to create my own lua function that calls this lua function and packages the result in a way that radiant.call_obj(...)
can understand? If so, how do I do that (i.e., namespace, manifest, mixin, etc.)? And if not, how do I proceed?