Sign in to follow this  
Micklo202

URGENT: Renaming the books?

Recommended Posts

Micklo202    5

Hello and thank you soo much for taking the time to read this!

basically what im trying to do is rename all of wickerbottom's books and place them into a new custom tab with different craft materials for a MOD character. So far i've managed to successfully recreate the Sleeping and Tentacle books and was able place them in my custom tab with other custom items. fully functioning. 

2Hbdcqm.jpg

but i came across a problem when i was recreating the "birds" book.; i'm able to place it into my custom tab no problem, but when i try to use it , it functions the same as the sleep book for some reason and doesn't summon the birds. at first i thought i placed the "sleep" code in my "bird" book but that wasn't the case... here's the code i've used for my bird book: 

function star_bird_book(inst, reader)
            local birdspawner = TheWorld.components.birdspawner
            if birdspawner == nil then
                return false
            end

            local pt = reader:GetPosition()

            reader.components.sanity:DoDelta(-50)
            
            --we can actually run out of command buffer memory if we allow for infinite birds
            local ents = TheSim:FindEntities(pt.x, pt.y, pt.z, 10, nil, nil, { "magicalbird" })
            if #ents > 30 then
                reader.components.talker:Say(GetString(reader, "ANNOUNCE_WAYTOOMANYBIRDS"))
            else
                local num = math.random(10, 20)
                if #ents > 20 then
                    reader.components.talker:Say(GetString(reader, "ANNOUNCE_TOOMANYBIRDS"))
                else
                    num = num + 10
                end
                reader:StartThread(function()
                    for k = 1, num do
                        local pos = birdspawner:GetSpawnPoint(pt)
                        if pos ~= nil then
                            local bird = birdspawner:SpawnBird(pos, true)
                            if bird ~= nil then
                               bird:AddTag("magicalbird")
                            end
                        end
                        Sleep(math.random(.2, .25))
                    end
                end)
            end

            return true
        end

im able to spawn and read the "original birds book" and it works perfectly but for some reason my custom birds book won't work,... can you please take a look at my star_bird_book.lua and also wickerbottom's books.lua to let me know where i messed up? could it be that i have to add the bird spawner tag into my star.lua?  im new to all of this... still learning

thanks so much in advance!

Edited by Micklo202

Share this post


Link to post
Share on other sites
Lumina    2153

Again, what is urgent exactly ?



    inst:AddComponent("inspectable")
    inst:AddComponent("book")
    inst.components.book.onread = star_sleep_book

Maybe this is the problem.

Share this post


Link to post
Share on other sites
Micklo202    5

Sorry about that URGENT status. It's only because I've posted this topic 2 days ago and didn't get replies sadly. So I've reposted with it.  Won't happen again. 

 

And OMG I'm so silly... After all these hours it was right in from of me all this time....  Jeez I need start triple checking my files from now on! Thanks so much for pointing that out my friend. 

 

Share this post


Link to post
Share on other sites
Lumina    2153

Yes, sometimes people can't answer right now. It's ok to repost after some days as long as you don't spam.

I'm glad i helped. Sometimes it takes an external viewpoint to see some mistakes. But of course, if you can find them yourself it will be better. Especially because you don't need to wait for someone else :D

Share this post


Link to post
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
Sign in to follow this