Jump to content

How to tell if a player has something prototyped or not


Recommended Posts

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

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

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
  • Create New...