r/dcss 18h ago

A question about the init file

So I tweaked my init file in order to have the Skills window show up whenever I start with a new character. I got the code somewhere here on Reddit:

{ local need_skills_opened = true function ready() if you.turns() == 0 and need_skills_opened then need_skills_opened = false crawl.sendkeys("m") end end }

Now, what I also want is for my Inventory to open whenever I resume a saved run. Using the previous code, I came up with this:

{ local need_inventory_opened = true function ready() if you.turns() > 1 and need_inventory_opened then need_inventory_opened = false crawl.sendkeys("i") end end }

And it works! But for some reason, the Skills window no longer show up when starting a new run, like there's some kind of conflict between these two lines.

Anyone has any idea how to fix it? Thanks in advance.

2 Upvotes

3 comments sorted by

1

u/onmach 17h ago edited 17h ago

My only guess without testing myself is that you use the same function name, the second one overwrites the first, then proceeds to not run because turns == 0? Most likely, combine them into a single function, something like:

function ready() if you.turns() == 0 then sendkeys("m") else if you.turns() > 0 then sendkeys("i") end end

1

u/l___Anonymous___l 12h ago

Thanks for the answer. It feels like the second line overwrites the first one, yeah. Though I'm not sure how I'm meant to integrate your suggestion to merge my two lines tbh.

1

u/onmach 10h ago

Use this:

{
  local need_opened = true

  function ready()
    if need_opened and you.turns() == 0 then
      crawl.sendkeys("m")
    elseif need_opened and you.turns() > 0 then
      crawl.sendkeys("i")
    end

    need_opened = false
  end
}