Sohjiro Posted September 7, 2019 Share Posted September 7, 2019 I'm trying to make an update for my mod and want to be able to tell if a player standing near the Alchemy Machine has a specific item prototyped already. Link to comment Share on other sites More sharing options...
Ultroman Posted September 7, 2019 Share Posted September 7, 2019 if inst.components.builder:KnowsRecipe(recipename) Be advised that if you're using this on a client, you have to go through the builder_replica component, which has the same function. Link to comment Share on other sites More sharing options...
Sohjiro Posted September 7, 2019 Author Share Posted September 7, 2019 thanks so much for the reply. Im trying to write a function that can tell if there is a Player with a specific recipe close to the Alchemy Engine and return true or false. Similar to this one i wrote to see if a Shadow Manipulator is close local function hasShadowManipulator(inst) local x, y, z = inst.Transform:GetWorldPosition() return #TheSim:FindEntities(x, y, z, 10, { "level3" }) > 0 end Im not really sure how to accomplish this tbh idk LUA that well but i would think i would get an array of players close to the machine and then loop through them to check if anyone has the recipe but im not sure how to exactly pull that off in LUA code Link to comment Share on other sites More sharing options...
Ultroman Posted September 8, 2019 Share Posted September 8, 2019 What are you actually trying to do? What's the purpose? It seems weird to be continuously checking for players being near the prototypers. Link to comment Share on other sites More sharing options...
Sohjiro Posted September 8, 2019 Author Share Posted September 8, 2019 It wouldn't be continuous I made a mod called Lazy Refining where it adds a container to the Science Machine to mass refine items. It only runs on the onClose function of the container and I want to be able to let players mass refine budling wraps but only if they have they've already acquired the recipe. https://steamcommunity.com/sharedfiles/filedetails/?id=928938995 Link to comment Share on other sites More sharing options...
Ultroman Posted September 8, 2019 Share Posted September 8, 2019 Aha, ok. Well, in onclose you have the "doer" as the second parameter, which is the entity that closed the container. You can then check: if doer.components.builder:KnowsRecipe(recipename) If that doesn't work for you, you can always just to a FindEntities call to find players around the container, to see if any of them knows the recipe, but then you would be allowing the situation where two players are standing near the machine, and one knows the recipe but the player who is actually using the machine does not know the recipe. You can work around that problem, but it would be easier if the first proposition works. Link to comment Share on other sites More sharing options...
Sohjiro Posted September 11, 2019 Author Share Posted September 11, 2019 that worked perfectly thanks for all the help Link to comment Share on other sites More sharing options...
Ultroman Posted September 11, 2019 Share Posted September 11, 2019 You're welcome! Link to comment 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