droooney Posted March 28, 2022 Share Posted March 28, 2022 I'm the author of the Crafting Guide Mod. Before the update the mod was able to utilize DoRecipeClick function from custom ui to craft items. This stopped working for non-structure crafts after the crafting update and I can't figure out why. Placing a structure using this function still works though Link to comment https://forums.kleientertainment.com/forums/topic/138694-dorecipeclick-stopped-working-after-the-crafting-update/ Share on other sites More sharing options...
GodIess Posted March 29, 2022 Share Posted March 29, 2022 if recipe_data ~= nil then local already_buffered = self.owner.replica.builder:IsBuildBuffered(recipe_data.recipe.name) local stay_open, error_msg = _G.DoRecipeClick(self.owner, recipe_data.recipe, self.skin_name) if not stay_open then self.owner:PushEvent("refreshcrafting") -- this is only really neede for free crafting if already_buffered or Profile:GetCraftingMenuBufferedBuildAutoClose() then self.owner.HUD:CloseCrafting() end end if error_msg and not TheNet:IsServerPaused() then _G.SendRPCToServer(_G.RPC.CannotBuild, error_msg) end end this code is used for create button Link to comment https://forums.kleientertainment.com/forums/topic/138694-dorecipeclick-stopped-working-after-the-crafting-update/#findComment-1553623 Share on other sites More sharing options...
Monti18 Posted March 30, 2022 Share Posted March 30, 2022 (edited) The problem is this snippet of the DoRecipeClick fn: if owner.components.playercontroller ~= nil then local iscontrolsenabled, ishudblocking = owner.components.playercontroller:IsEnabled() if not (iscontrolsenabled or ishudblocking) then --Ignore button click when controls are disabled --but not just because of the HUD blocking input return true end end This will return false, as playercontroller:IsEnabled will return false,nil Spoiler function PlayerController:IsEnabled() if self.classified == nil or not self.classified.iscontrollerenabled:value() then return false elseif self.inst.HUD ~= nil and self.inst.HUD:HasInputFocus() then return false, self.inst.HUD:IsCraftingOpen() and TheFrontEnd.textProcessorWidget == nil end return true end You could try to hook into the inst.HUD:IsCraftingOpen() function and make it so that your widget returns true if it's there or hook any other function on the way. Edit: A quick fix would be this: Spoiler AddClassPostConstruct("screens/playerhud",function(self) local old_IsCraftingOpen = self.IsCraftingOpen function self:IsCraftingOpen(...) local activeScreen = TheFrontEnd:GetActiveScreen() if activeScreen and activeScreen.name == "Root" then return true else return old_IsCraftingOpen(self,...) end end end) Edited March 30, 2022 by Monti18 1 Link to comment https://forums.kleientertainment.com/forums/topic/138694-dorecipeclick-stopped-working-after-the-crafting-update/#findComment-1553812 Share on other sites More sharing options...
droooney Posted March 30, 2022 Author Share Posted March 30, 2022 7 hours ago, Monti18 said: The problem is this snippet of the DoRecipeClick fn: if owner.components.playercontroller ~= nil then local iscontrolsenabled, ishudblocking = owner.components.playercontroller:IsEnabled() if not (iscontrolsenabled or ishudblocking) then --Ignore button click when controls are disabled --but not just because of the HUD blocking input return true end end This will return false, as playercontroller:IsEnabled will return false,nil Reveal hidden contents function PlayerController:IsEnabled() if self.classified == nil or not self.classified.iscontrollerenabled:value() then return false elseif self.inst.HUD ~= nil and self.inst.HUD:HasInputFocus() then return false, self.inst.HUD:IsCraftingOpen() and TheFrontEnd.textProcessorWidget == nil end return true end You could try to hook into the inst.HUD:IsCraftingOpen() function and make it so that your widget returns true if it's there or hook any other function on the way. Edit: A quick fix would be this: Reveal hidden contents AddClassPostConstruct("screens/playerhud",function(self) local old_IsCraftingOpen = self.IsCraftingOpen function self:IsCraftingOpen(...) local activeScreen = TheFrontEnd:GetActiveScreen() if activeScreen and activeScreen.name == "Root" then return true else return old_IsCraftingOpen(self,...) end end end) Thank you so much! I'm definitely gonna implement this solution Link to comment https://forums.kleientertainment.com/forums/topic/138694-dorecipeclick-stopped-working-after-the-crafting-update/#findComment-1553867 Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now