Jump to content

Need help with inst.components


Recommended Posts

How can i use inst.components.builder:UnlockRecipe("prefab")  and inst.components.reader:Say("string") inside inst.components.book.onread function? I want to create a book that would unlock recipe after reading but as a result i always get error:

[string "../mods/test/scripts/prefabs/book_science.l..."]:85: attempt to index field 'builder' (a nil value)

P.S. Sorry for my english

Link to comment
Share on other sites

inst.components.book.onread = function(owner, reader)
    if reader.components.builder
    then
        reader.components.builder:UnlockRecipe("prefab")
    end
    if reader.components.talker
    then
        reader.components.talker:Say("Bob")
    end
    return true -- Or whatever checks you want to make it not do anything.
end

I think you're trying to use the book component's inst as a reference to the builder/talker component instead of the reader.

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...