Jump to content

How to make reusable books and other items?


Archsaint

Recommended Posts

Greetings, I'm working on my first mod and I've reached a dead end.

 

I need a book (not a skill book) to be 'not consumed' after reading, have its page count reset, and also give the benefit of BoredomChange and UnhappyChange after only reading for maybe 15 or 20 pages (instead of having to complete the entire book - it's a big book). I tried ReplaceOnDeplete, and some other things but nothing works.

 

Also for future modding, how would you add the 'not consumed' property to say food or a cigarette?

 

I have tried to reverse engineer this from other mods and have searched forum posts to no avail. Seems like a simple thing to do, but I'm not a coder. There are some mods that do this for every book, such as the Reset Page Read mod, but I'd rather not require another mod for mine to function as desired if possible. Any help is appreciated!

Link to comment
Share on other sites

I want to help but I cant find what I want. Instead of having it not be consumed or having the page recount set, I want to find where the code is that makes the book disappear when finished and add a check for if its a book have it spawn another book after, that way you still have a book even if its not the same book. Im looking in Project Zomboid\media\lua\client\TimedActions\ISReadABook.lua and I cant find anything that would do that except maybe 

    if self.item:getNumberOfPages() > 0 then
        local pagesRead = math.floor(self.item:getNumberOfPages() * self:getJobDelta())
        self.item:setAlreadyReadPages(pagesRead);
        if self.item:getAlreadyReadPages() > self.item:getNumberOfPages() then
            self.item:setAlreadyReadPages(self.item:getNumberOfPages());
        end
        self.character:setAlreadyReadPages(self.item:getFullType(), self.item:getAlreadyReadPages())
But I cant see where it links to to get rid of the book after. I tried searching the rest of the files but theres nothing I can find.
I think the best bet if thats not possible is to make normal books not disappear like skill books then just make a recipe where you can turn 1 book into 1 book, the new book wouldnt hvae been read. You can just call the recipe reread book or something, but I cant think of a way to do that either without playing around for half an hour+ it seems like a simple addition of         DisplayCategory = SkillBook,   to the top line but I dont know what other changes that would cause like would you be able to read it again after regardless.
Link to comment
Share on other sites

Thanks for looking into my issue Betcher! You are right, skill books don't disappear when read and that was an option. But I was able to get the game to add the same book after it was 'consumed' by adding ReplaceOnUse = (the book) in the item code. However you don't get the benefits from reading the book again, as it's marked read. With the Reset Page Read mod it suffices for now.

Link to comment
Share on other sites

  • 2 months later...
On 10/16/2023 at 3:42 PM, Betcher said:

I want to help but I cant find what I want. Instead of having it not be consumed or having the page recount set, I want to find where the code is that makes the book disappear when finished and add a check for if its a book have it spawn another book after, that way you still have a book even if its not the same book. Im looking in Project Zomboid\media\lua\client\TimedActions\ISReadABook.lua and I cant find anything that would do that except maybe 

    if self.item:getNumberOfPages() > 0 then
        local pagesRead = math.floor(self.item:getNumberOfPages() * self:getJobDelta())
        self.item:setAlreadyReadPages(pagesRead);
        if self.item:getAlreadyReadPages() > self.item:getNumberOfPages() then
            self.item:setAlreadyReadPages(self.item:getNumberOfPages());
        end
        self.character:setAlreadyReadPages(self.item:getFullType(), self.item:getAlreadyReadPages())
But I cant see where it links to to get rid of the book after. I tried searching the rest of the files but theres nothing I can find.
I think the best bet if thats not possible is to make normal books not disappear like skill books then just make a recipe where you can turn 1 book into 1 book, the new book wouldnt hvae been read. You can just call the recipe reread book or something, but I cant think of a way to do that either without playing around for half an hour+ it seems like a simple addition of         DisplayCategory = SkillBook,   to the top line but I dont know what other changes that would cause like would you be able to read it again after regardless.  Thank you for supplying this information. This is very appreciated by me because it facilitates the educational process. Furthermore, this is not always clear. I'm now preparing to write letter of recommendation that is proving difficult for me https://www.lorservice.com/medical-school-letter-of-recommendation-writing-service/ I needed profesional help. This is the best option because I couldn't accomplish it on my own.

Very important information for me, thank you

Edited by ArthurWeatherford
Link to comment
Share on other sites

On 10/16/2023 at 3:42 PM, Betcher said:

I want to help but I cant find what I want. Instead of having it not be consumed or having the page recount set, I want to find where the code is that makes the book disappear when finished and add a check for if its a book have it spawn another book after, that way you still have a book even if its not the same book. Im looking in Project Zomboid\media\lua\client\TimedActions\ISReadABook.lua and I cant find anything that would do that except maybe 

    if self.item:getNumberOfPages() > 0 then
        local pagesRead = math.floor(self.item:getNumberOfPages() * self:getJobDelta())
        self.item:setAlreadyReadPages(pagesRead);
        if self.item:getAlreadyReadPages() > self.item:getNumberOfPages() then
            self.item:setAlreadyReadPages(self.item:getNumberOfPages());
        end
        self.character:setAlreadyReadPages(self.item:getFullType(), self.item:getAlreadyReadPages())
But I cant see where it links to to get rid of the book after. I tried searching the rest of the files but theres nothing I can find.
I think the best bet if thats not possible is to make normal books not disappear like skill books then just make a recipe where you can turn 1 book into 1 book, the new book wouldnt hvae been read. You can just call the recipe reread book or something, but I cant think of a way to do that either without playing around for half an hour+ it seems like a simple addition of         DisplayCategory = SkillBook,   to the top line but I dont know what other changes that would cause like would you be able to read it again after regardless. In the Essays.Edubirdie https://essays.edubirdie.com/marketing-assignment-help realm, creative problem-solving aligns with our approach to academic challenges. Perhaps a collaborative forum discussion with fellow modders or reaching out to the game's developer community could yield insights. Remember, the beauty of coding lies in experimentation, and your efforts may unlock a novel solution.

Thanks a lot! 

Edited by BettyPiper
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
×
×
  • Create New...