So I’m trying to create a new box selector, much like the harvest tool, but when I call this code:
compactify.js:
$(top).one('start_menu_activated', function () {
App.stonehearthClient.compactify = function (){
var tip = this.showTip('compactify:ui.compactify_tool.tip_title',
'compactify:ui.compactify_tool.tip_description', {i18n : true});
return this._callTool('boxHarvestResources', function() {
return radiant.call('compactify:box_compactify')
.done(function(response) {
radiant.call('radiant:play_sound', {'track' : 'stonehearth:sounds:ui:start_menu:popup'} );
})
.fail(function(response) {
App.stonehearthClient.hideTip(tip);
});
});
};
var compactifyZoneElem = $('#compactify_zone');
compactifyZoneElem.on('click', function(e){
App.stonehearthClient.compactify();
});
});
compactify_call_handler.lua:
stonehearth.selection:select_xz_region('box_compactify')
:set_find_support_filter(function(result)
if self:_is_ground(result.entity) then
return true
end
return stonehearth.selection.FILTER_IGNORE
end)
:done(function(selector, box)
_radiant.call('compactify:server_box_compactify', box)
response:resolve(true)
end)
:fail(function(selector)
response:reject('no region')
end)
:go()
I know the code gets reach because I can output the response to console through js. However, for the life of me I cannot debug the reason as to why it automatically fail()s. From what I can discern, it calls SelectionService:deactivate_all_tools() -> tool:destroy() automatically, so I get no change to drag the region.
Anyone know how to help??