Tweak this function to include scarves?


Problems running or configuring the software, commands & options, compiling, different platforms, using the interface, documentation, etc.

Mines Malingerer

Posts: 36

Joined: Monday, 31st October 2011, 01:38

Post Sunday, 29th October 2017, 04:36

Tweak this function to include scarves?

I just got back into the game after a while, and noticed that if I had a scarf equipped, I was automatically picking up every cloak I found, because of this great quality-of-life function I'd found and put in my init.txt. Could someone show me how to adjust it to account for scarves too, so that I'll only automatically pick up plain cloaks when I have neither a cloak nor a scarf equipped?

  Code:
  if (class == "armour") then
      if it.is_useless then return false end

    sub_type = it.subtype()
    equipped_item = items.equipped_at(armour_slots[sub_type])

    if (sub_type == "cloak") or (sub_type == "helmet") or (sub_type == "gloves") or (sub_type == "boots") then
      if not equipped_item then
        return true
      else
        return it.artefact or it.branded or it.ego
      end
    end

Swamp Slogger

Posts: 148

Joined: Tuesday, 19th May 2015, 09:51

Post Sunday, 29th October 2017, 13:12

Re: Tweak this function to include scarves?

this one is similar but works like you want it to. why is beyond me though, at a glance they seem to do the same thing, but i'm not very familiar with the syntax.

  Code:
{
add_autopickup_func(function(it, name)
  if it.is_useless then
    return
  end
  if it.class(true) == "armour" then
    local good_slots = {cloak="Cloak", helmet="Helmet", gloves="Gloves",
                        boots="Boots"}
    st, _ = it.subtype()
    if good_slots[st] ~= nil and items.equipped_at(good_slots[st]) == nil then
      return true
    end
  end
end)
}

Mines Malingerer

Posts: 36

Joined: Monday, 31st October 2011, 01:38

Post Sunday, 29th October 2017, 16:29

Re: Tweak this function to include scarves?

emikaela wrote:this one is similar but works like you want it to. why is beyond me though, at a glance they seem to do the same thing, but i'm not very familiar with the syntax.

  Code:
{
add_autopickup_func(function(it, name)
  if it.is_useless then
    return
  end
  if it.class(true) == "armour" then
    local good_slots = {cloak="Cloak", helmet="Helmet", gloves="Gloves",
                        boots="Boots"}
    st, _ = it.subtype()
    if good_slots[st] ~= nil and items.equipped_at(good_slots[st]) == nil then
      return true
    end
  end
end)
}


EDIT: Or maybe it is, and I pasted it wrong at first...testing.

This doesn't seem to be working, as I just came across a pair of gloves, while not having any gloves, and it didn't want to automatically pick them up.

Return to Technical Support

Who is online

Users browsing this forum: No registered users and 1 guest

Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.